Skip to content

Remove redundant @jest-environment jsdom pragma and lint against it - #80676

Merged
manzoorwanijk merged 2 commits into
trunkfrom
fix/no-jsdom-jest-environment-pragma
Jul 24, 2026
Merged

Remove redundant @jest-environment jsdom pragma and lint against it#80676
manzoorwanijk merged 2 commits into
trunkfrom
fix/no-jsdom-jest-environment-pragma

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Member

What?

Follow up to #77563 (comment)

Removes the @jest-environment jsdom pragma that #77563 reintroduced, and adds an ESLint rule so it does not come back.

Why?

#79672 removed these pragmas repo-wide. jsdom is already the default testEnvironment in @wordpress/jest-preset-default, so the pragma is a no-op, and it breaks under the isolated node_modules layout.

Since nothing prevented it from being added back, a lint rule is needed alongside the removal.

How?

  • Deleted the pragma docblock from packages/block-library/src/navigation/test/view.js.
  • Added no-warning-comments with @jest-environment jsdom as a banned term to the existing Jest override block in tools/eslint/config.mjs. It is the only core ESLint rule that inspects comment text, so no custom rule is needed. The rule's rules object is re-spread from eslint-plugin-jest's recommended config so the plugin's own rules stay active.

Scoped to **/test/** and **/__tests__/**, excluding e2e/performance/storybook-playwright. @jest-environment node pragmas are genuine overrides and remain untouched.

Testing Instructions

  1. npm run lint:js -- packages/block-library/src/navigation/test/view.js passes.
  2. Re-add the pragma to any unit test file and confirm ESLint errors with no-warning-comments.
  3. Confirm the node overrides still lint clean:
    npm run lint:js -- packages/compose/src/hooks/use-media-query/test/ssr.js packages/vips/src/test packages/theme/src/stylelint-plugins/test
    
  4. npm run test:unit -- packages/block-library/src/navigation/test/view.js passes under the default jsdom environment.

Testing Instructions for Keyboard

N/A — test and tooling only, no UI.

Screenshots or screencast

N/A

Use of AI Tools

This pull request was authored with assistance from Claude Code. All changes were reviewed by the contributor.

jsdom is already the default testEnvironment in @wordpress/jest-preset-default,
so the pragma is a no-op and breaks under the isolated node_modules layout.

Follow up to #77563, which reintroduced the pragma removed in #79672.
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jul 24, 2026
@manzoorwanijk manzoorwanijk added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 24, 2026
@manzoorwanijk
manzoorwanijk marked this pull request as ready for review July 24, 2026 10:39
@github-actions

github-actions Bot commented Jul 24, 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: aduth <aduth@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.75 MB

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in fc5c087.
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/30086843667
📝 Reported issues:

@aduth aduth left a comment

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.

LGTM 👍 Confirmed that the test still passes and that trying to re-add the comment yields a lint error.

Comment thread tools/eslint/config.mjs Outdated
Comment thread tools/eslint/config.mjs
@manzoorwanijk
manzoorwanijk enabled auto-merge (squash) July 24, 2026 13:09
@manzoorwanijk
manzoorwanijk merged commit 8467aab into trunk Jul 24, 2026
55 of 59 checks passed
@manzoorwanijk
manzoorwanijk deleted the fix/no-jsdom-jest-environment-pragma branch July 24, 2026 15:03
@github-actions github-actions Bot added this to the Gutenberg 23.7 milestone Jul 24, 2026
@t-hamano

Copy link
Copy Markdown
Contributor

Since #77563 was backported to 7.1, let's backport this PR as well.

@t-hamano t-hamano added the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 29, 2026
@github-actions github-actions Bot removed the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 29, 2026
gutenbergplugin pushed a commit that referenced this pull request Jul 29, 2026
…80676)

Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Jul 29, 2026
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: d312a5a

dd32 pushed a commit to dd32/wordpress-develop that referenced this pull request Jul 29, 2026
This updates the pinned commit hash of the Gutenberg repository from `4997026b75c922d8a6f77a03d72ed7cad04c7073` to `fd715a6833679d098d9fee84b642f8f1bc27341b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@4997026...fd715a6

- Update view config API versioning (WordPress/gutenberg#80319)
- Perf Tests: Fix 'Selecting blocks' metric reporting 0 ms (WordPress/gutenberg#80524)
- Notes: Register the inline note format at import time (WordPress/gutenberg#80576)
- Media: Stop forcing crossorigin on IMG tags in media templates (WordPress/gutenberg#80532)
- GradientPicker: select by slug so two presets sharing a gradient keep their identity (WordPress/gutenberg#80554)
- Media Editor: Show a loading state while the cropped file loads (WordPress/gutenberg#80460)
- Remove default paragraph from tab-panel template (WordPress/gutenberg#80565)
- Global Styles: Resolve link element styles in block inspector controls for blocks that are links (WordPress/gutenberg#80607)
- Media REST API: Backport sideload from url path upload size check (WordPress/gutenberg#80659)
- Rich text: remove tabIndex from editable elements again to fix shift+click selection (WordPress/gutenberg#80651)
- Gallery: make dynamic mode conversion a single undo level (WordPress/gutenberg#80665)
- Background image control: Remove duplicated focus ring (WordPress/gutenberg#80671)
- Detach core's note mention kses filter in the baseline strip test (WordPress/gutenberg#80656)
- wp-build: sync the page template preload field list with core-data (WordPress/gutenberg#80648)
- Read the contentEditable attribute in ownsSelection, not isContentEditable (WordPress/gutenberg#80549)
- Writing flow: extend block selections with shift+arrow when there is no native selection (WordPress/gutenberg#80687)
- Notes: Capture the target block before saving a block-level note (WordPress/gutenberg#80690)
- Theme JSON: Level block-level preset class specificity with :where() (WordPress/gutenberg#80657)
- Notes: Sync the sidebar selection to the inline marker under the caret (WordPress/gutenberg#80610)
- Writing flow: use isMultiSelecting for shift+click (WordPress/gutenberg#80286) (WordPress/gutenberg#80726)
- Block supports: Return from layout support before resolving global settings (WordPress/gutenberg#80771)
- Notes: Report save success consistently from note actions (WordPress/gutenberg#80748)
- Dynamic Gallery: Rename toolbar button to Detach and add a modal explaining what will happen (WordPress/gutenberg#80727) (WordPress/gutenberg#80774)
- ToolsPanel: Migrate styles to an SCSS Module (WordPress/gutenberg#80445) (WordPress/gutenberg#80800)
- Add a responsiveEditingEnabled editor setting to hide the Responsive styles option (WordPress/gutenberg#80814)
- iOS: remove jumping hack, add typewriter (WordPress/gutenberg#74596)
- Writing flow: stop the page scrolling on caret moves within blocks taller than the viewport (WordPress/gutenberg#80708)
- Global Styles: Put the inheritance UI behind a Gutenberg experiment (… (WordPress/gutenberg#80818)
- Notes: Cancel in-flight hover highlight when focus leaves a note thread (WordPress/gutenberg#80752)
- Block Editor: Try to fix typing performance regression (WordPress/gutenberg#80507)
- List Block: Preserve ordered type on indent (WordPress/gutenberg#75353)
- Make editableRoot a private block setting Symbol, not a public support (WordPress/gutenberg#80820)
- Fix cursor position during forward delete of empty blocks (WordPress/gutenberg#80827)
- Navigation: Fixes `aria-expanded` not updating on hover submenu inside overlay (WordPress/gutenberg#80828)
- Remove redundant @jest-environment jsdom pragma and lint against it (WordPress/gutenberg#80676)
- View config: reject shape-mismatched merges, define empty-array semantics, strip nulls from appended members (WordPress/gutenberg#80829)
- Editor: leave undo to the browser in fields that handle their own undo (WordPress/gutenberg#80768)
- Fix: New route-based admin pages are empty when no JS (WordPress/gutenberg#80839)

Props wildworks.
See #65529.

git-svn-id: https://develop.svn.wordpress.org/trunk@62896 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jul 29, 2026
This updates the pinned commit hash of the Gutenberg repository from `4997026b75c922d8a6f77a03d72ed7cad04c7073` to `fd715a6833679d098d9fee84b642f8f1bc27341b`.

A full list of changes included in this commit can be found on GitHub: 
WordPress/gutenberg@4997026...fd715a6

- Update view config API versioning (WordPress/gutenberg#80319)
- Perf Tests: Fix 'Selecting blocks' metric reporting 0 ms (WordPress/gutenberg#80524)
- Notes: Register the inline note format at import time (WordPress/gutenberg#80576)
- Media: Stop forcing crossorigin on IMG tags in media templates (WordPress/gutenberg#80532)
- GradientPicker: select by slug so two presets sharing a gradient keep their identity (WordPress/gutenberg#80554)
- Media Editor: Show a loading state while the cropped file loads (WordPress/gutenberg#80460)
- Remove default paragraph from tab-panel template (WordPress/gutenberg#80565)
- Global Styles: Resolve link element styles in block inspector controls for blocks that are links (WordPress/gutenberg#80607)
- Media REST API: Backport sideload from url path upload size check (WordPress/gutenberg#80659)
- Rich text: remove tabIndex from editable elements again to fix shift+click selection (WordPress/gutenberg#80651)
- Gallery: make dynamic mode conversion a single undo level (WordPress/gutenberg#80665)
- Background image control: Remove duplicated focus ring (WordPress/gutenberg#80671)
- Detach core's note mention kses filter in the baseline strip test (WordPress/gutenberg#80656)
- wp-build: sync the page template preload field list with core-data (WordPress/gutenberg#80648)
- Read the contentEditable attribute in ownsSelection, not isContentEditable (WordPress/gutenberg#80549)
- Writing flow: extend block selections with shift+arrow when there is no native selection (WordPress/gutenberg#80687)
- Notes: Capture the target block before saving a block-level note (WordPress/gutenberg#80690)
- Theme JSON: Level block-level preset class specificity with :where() (WordPress/gutenberg#80657)
- Notes: Sync the sidebar selection to the inline marker under the caret (WordPress/gutenberg#80610)
- Writing flow: use isMultiSelecting for shift+click (WordPress/gutenberg#80286) (WordPress/gutenberg#80726)
- Block supports: Return from layout support before resolving global settings (WordPress/gutenberg#80771)
- Notes: Report save success consistently from note actions (WordPress/gutenberg#80748)
- Dynamic Gallery: Rename toolbar button to Detach and add a modal explaining what will happen (WordPress/gutenberg#80727) (WordPress/gutenberg#80774)
- ToolsPanel: Migrate styles to an SCSS Module (WordPress/gutenberg#80445) (WordPress/gutenberg#80800)
- Add a responsiveEditingEnabled editor setting to hide the Responsive styles option (WordPress/gutenberg#80814)
- iOS: remove jumping hack, add typewriter (WordPress/gutenberg#74596)
- Writing flow: stop the page scrolling on caret moves within blocks taller than the viewport (WordPress/gutenberg#80708)
- Global Styles: Put the inheritance UI behind a Gutenberg experiment (… (WordPress/gutenberg#80818)
- Notes: Cancel in-flight hover highlight when focus leaves a note thread (WordPress/gutenberg#80752)
- Block Editor: Try to fix typing performance regression (WordPress/gutenberg#80507)
- List Block: Preserve ordered type on indent (WordPress/gutenberg#75353)
- Make editableRoot a private block setting Symbol, not a public support (WordPress/gutenberg#80820)
- Fix cursor position during forward delete of empty blocks (WordPress/gutenberg#80827)
- Navigation: Fixes `aria-expanded` not updating on hover submenu inside overlay (WordPress/gutenberg#80828)
- Remove redundant @jest-environment jsdom pragma and lint against it (WordPress/gutenberg#80676)
- View config: reject shape-mismatched merges, define empty-array semantics, strip nulls from appended members (WordPress/gutenberg#80829)
- Editor: leave undo to the browser in fields that handle their own undo (WordPress/gutenberg#80768)
- Fix: New route-based admin pages are empty when no JS (WordPress/gutenberg#80839)

Props wildworks.
See #65529.
Built from https://develop.svn.wordpress.org/trunk@62896


git-svn-id: http://core.svn.wordpress.org/trunk@62163 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] Block library /packages/block-library [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants