You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ce1b60f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(@schematics/angular): transform fail() to expect.fail() in refactor-jasmine-vitest
Previously, fail() calls in Jasmine specs were transformed into throw new Error(...). In Vitest, expect.fail(...) is the idiomatic assertion method to explicitly fail a test with an AssertionError, properly formatting test failures in test runner output and avoiding generic unhandled exception throws.
This update converts fail(...) call expressions to expect.fail(...), registers expect in the pending Vitest value imports, and moves the transformer into the call expression transformers pipeline.
description: 'should transform fail() to throw new Error()',
62
+
description: 'should transform fail() to expect.fail()',
63
63
input: `fail('This should not happen');`,
64
-
expected: `throw new Error('This should not happen');`,
64
+
expected: `expect.fail('This should not happen');`,
65
65
},
66
66
{
67
-
description: 'should transform fail() without a message to throw new Error()',
67
+
description: 'should transform fail() without a message to expect.fail()',
68
68
input: `fail();`,
69
-
expected: `throw new Error();`,
69
+
expected: `expect.fail();`,
70
70
},
71
71
{
72
72
description: 'should transform fail() with an Error object',
73
73
input: `fail(new TypeError('Invalid input'));`,
74
-
expected: `throw new TypeError('Invalid input');`,
74
+
expected: `expect.fail('Invalid input');`,
75
+
},
76
+
{
77
+
description: 'should transform fail() with an empty Error object',
78
+
input: `fail(new Error());`,
79
+
expected: `expect.fail();`,
80
+
},
81
+
{
82
+
description: 'should transform fail() with a non-string argument and add a TODO note',
83
+
input: `fail(err);`,
84
+
// eslint-disable-next-line max-len
85
+
expected: `// TODO: vitest-migration: expect.fail() only accepts a string message. Verify that converting this argument with String() produces the expected failure output. See: https://vitest.dev/api/expect.html#expect-fail
0 commit comments