Vitest: Resolve @flakiness/vitest reporter to an absolute path - #81582
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 7.72 MB |
| * Resolve to an absolute path so Vitest can load | ||
| * the reporter regardless of hoisting layout. | ||
| */ | ||
| createRequire( import.meta.url ).resolve( |
There was a problem hiding this comment.
The pattern seems to be to call const require = createRequire( import.meta.url ) at file level and then require.resolve.
There was a problem hiding this comment.
I don't have a strong preference about it and we don't have any guidelines about it.
|
Flaky tests detected in 8a780ac. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31706830327 should allow a block with styles to be converted to a reusable block in
|
What?
Follow up to #81037 (comment)
Resolves the
@flakiness/vitestreporter to an absolute path in test/unit/vitest.config.mjs usingcreateRequire( import.meta.url ).resolve().Why?
With the bare specifier, Vitest fails to load the reporter under the isolated node_modules install strategy, since the package isn't hoisted where Vitest looks for it. See this failing run.
How?
createRequire( import.meta.url )resolves the package relative to the config file, so the reporter loads regardless of the hoisting layout.Testing Instructions
npm run test:unit:vitest.Use of AI Tools
Authored with the assistance of Claude Code, reviewed and taken responsibility for by the author.