Skip to content

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

Merged
dgp1130 merged 1 commit into
angular:mainfrom
clydin:fix-vitest-fail-refactor
Aug 17, 2026
Merged

fix(@schematics/angular): transform fail() to expect.fail() in refactor-jasmine-vitest#33865
dgp1130 merged 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
@alan-agius4 alan-agius4 linked an issue Aug 17, 2026 that may be closed by this pull request
1 task
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 17, 2026
@alan-agius4
alan-agius4 removed the request for review from hawkgs August 17, 2026 07:53
@dgp1130
dgp1130 merged commit ce1b60f into angular:main Aug 17, 2026
41 checks passed
@dgp1130

dgp1130 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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.

refactor-jasmine-vitest refactors fail() call incorrectly

4 participants