Merge pull request #29458 from storybookjs/hide-assertion-error-stacktrace

Addon Test: Fix hiding stacktrace for assertion errors in test panel
This commit is contained in:
Valentin Palkovic 2024-10-28 10:12:36 +01:00 committed by GitHub
commit e0f287775e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View File

@ -103,6 +103,7 @@
"react-dom": "^18.2.0",
"semver": "^7.6.3",
"slash": "^5.0.0",
"strip-ansi": "^7.1.0",
"ts-dedent": "^2.2.0",
"typescript": "^5.3.2",
"vitest": "^2.1.3"

View File

@ -1,6 +1,7 @@
import { type StorybookTheme, useTheme } from 'storybook/internal/theming';
import Filter from 'ansi-to-html';
import stripAnsi from 'strip-ansi';
export function isTestAssertionError(error: unknown) {
return isChaiError(error) || isJestError(error);
@ -22,7 +23,7 @@ export function isJestError(error: unknown) {
typeof error === 'object' &&
'message' in error &&
typeof error.message === 'string' &&
error.message.startsWith('expect(')
stripAnsi(error.message).startsWith('expect(')
);
}

View File

@ -6253,6 +6253,7 @@ __metadata:
react-dom: "npm:^18.2.0"
semver: "npm:^7.6.3"
slash: "npm:^5.0.0"
strip-ansi: "npm:^7.1.0"
ts-dedent: "npm:^2.2.0"
typescript: "npm:^5.3.2"
vitest: "npm:^2.1.3"