Skip to content

fix(@schematics/angular): transform fail() to expect.fail() in refactor-jasmine-vitest - #33865

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-fail-refactor
Open

fix(@schematics/angular): transform fail() to expect.fail() in refactor-jasmine-vitest#33865
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-vitest-fail-refactor

Conversation

@clydin

@clydin clydin commented Aug 14, 2026

Copy link
Copy Markdown
Member

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.

@clydin clydin added the target: patch This PR is targeted for the next patch release label Aug 14, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Jasmine-to-Vitest transformer to convert Jasmine's fail() calls to Vitest's expect.fail() instead of throwing a new Error, and ensures expect is imported when needed. The feedback highlights that expect.fail() in Vitest/Chai only accepts a string argument, meaning passing an Error object directly will cause TypeScript compilation errors. It is recommended to extract the string message from Error instantiations and wrap non-string arguments in String() to ensure type safety, updating the corresponding unit and integration tests accordingly.

…or-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.
@clydin
clydin force-pushed the fix-vitest-fail-refactor branch from fa2827b to 2724099 Compare August 14, 2026 18:03
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 14, 2026
@clydin
clydin requested a review from hawkgs August 14, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @schematics/angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant