Skip to content

Vitest: Resolve @flakiness/vitest reporter to an absolute path - #81582

Merged
manzoorwanijk merged 1 commit into
trunkfrom
fix/vitest-flakiness-reporter-resolution
Aug 13, 2026
Merged

Vitest: Resolve @flakiness/vitest reporter to an absolute path#81582
manzoorwanijk merged 1 commit into
trunkfrom
fix/vitest-flakiness-reporter-resolution

Conversation

@manzoorwanijk

@manzoorwanijk manzoorwanijk commented Aug 13, 2026

Copy link
Copy Markdown
Member

What?

Follow up to #81037 (comment)

Resolves the @flakiness/vitest reporter to an absolute path in test/unit/vitest.config.mjs using createRequire( 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

  1. Run npm run test:unit:vitest.
  2. Confirm the tests run and the reporter loads without a module resolution error.

Use of AI Tools

Authored with the assistance of Claude Code, reviewed and taken responsibility for by the author.

@manzoorwanijk manzoorwanijk self-assigned this Aug 13, 2026
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Aug 13, 2026
@manzoorwanijk
manzoorwanijk marked this pull request as ready for review August 13, 2026 13:51
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.72 MB

compressed-size-action

* Resolve to an absolute path so Vitest can load
* the reporter regardless of hoisting layout.
*/
createRequire( import.meta.url ).resolve(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The pattern seems to be to call const require = createRequire( import.meta.url ) at file level and then require.resolve.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't have a strong preference about it and we don't have any guidelines about it.

@manzoorwanijk
manzoorwanijk enabled auto-merge (squash) August 13, 2026 14:04
@github-actions

Copy link
Copy Markdown

Flaky tests detected in 8a780ac.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/31706830327
📝 Reported tests:

should allow a block with styles to be converted to a reusable block in /test/e2e/specs/editor/various/patterns.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/posts?per_page=100&status=publish%2Cfuture%2Cdraft%2Cpending%2Cprivate%2Ctrash
    - user-agent: Playwright/1.62.1 (x64; ubuntu 24.04) node/20.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 833f63d57e
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1786802039%7CwnC1PlIGBdH2kyHXQzGhJlkDNd3dm6xHnTOsfEMuhs4%7C6f46ce6af7c4a3a1bc14535d50a096b1ddc512164c9b0494c968485f7638cf46; wp-settings-time-1=1786629602

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at RequestUtils.deleteAllPosts (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/posts.ts:30:27)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/patterns.spec.js:774:22

@manzoorwanijk
manzoorwanijk merged commit 6bef429 into trunk Aug 13, 2026
59 of 61 checks passed
@manzoorwanijk
manzoorwanijk deleted the fix/vitest-flakiness-reporter-resolution branch August 13, 2026 14:23
@github-actions github-actions Bot added this to the Gutenberg 23.9 milestone Aug 13, 2026
@jeryj jeryj added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. and removed [Type] Code Quality Issues or PRs that relate to code quality labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants