Skip to content

Commit 2576ac9

Browse files
authored
fix(testing-environment): should have Node on global (#1850)
`@testing-library/jest-dom` has published a new version [v6.9.0](https://github.com/testing-library/jest-dom/releases/tag/v6.9.0), which would reference the `Node` from global. See: testing-library/jest-dom#702 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Added a test script to run Vitest in the testing environment. - Bug Fixes - Fixed a “Node is not defined” error in Vitest setup, improving test stability. - Chores - Updated @testing-library/jest-dom to v6.9.0 across packages and templates. - Added patch dependencies: @lynx-js/react and @lynx-js/testing-environment. - Tests - Improved test environment configuration for compatibility with latest testing libraries. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ## Checklist <!--- Check and mark with an "x" --> - [ ] Tests updated (or not required). - [ ] Documentation updated (or not required). - [x] Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).
1 parent 80f5d60 commit 2576ac9

File tree

8 files changed

+28
-17
lines changed

8 files changed

+28
-17
lines changed

.changeset/hot-gifts-carry.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@lynx-js/react": patch
3+
"@lynx-js/testing-environment": patch
4+
---
5+
6+
Fix the "ReferenceError: Node is not defined" error.
7+
8+
This error would happen when upgrading to `@testing-library/jest-dom` [v6.9.0](https://github.com/testing-library/jest-dom/releases/tag/v6.9.0).

packages/react/testing-library/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"@lynx-js/react": "workspace:*",
1414
"@lynx-js/testing-environment": "workspace:*",
1515
"@testing-library/dom": "^10.4.1",
16-
"@testing-library/jest-dom": "^6.8.0"
16+
"@testing-library/jest-dom": "^6.9.0"
1717
}
1818
}

packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@lynx-js/qrcode-rsbuild-plugin": "workspace:*",
1717
"@lynx-js/react-rsbuild-plugin": "workspace:*",
1818
"@lynx-js/rspeedy": "workspace:*",
19-
"@testing-library/jest-dom": "^6.8.0",
19+
"@testing-library/jest-dom": "^6.9.0",
2020
"jsdom": "^26.1.0",
2121
"vitest": "^3.2.4"
2222
},

packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@lynx-js/rspeedy": "workspace:*",
1919
"@lynx-js/types": "3.4.11",
2020
"@rsbuild/plugin-type-check": "1.2.4",
21-
"@testing-library/jest-dom": "^6.8.0",
21+
"@testing-library/jest-dom": "^6.9.0",
2222
"@types/react": "^18.3.24",
2323
"jsdom": "^26.1.0",
2424
"typescript": "~5.9.2",

packages/testing-library/examples/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"devDependencies": {
1616
"@lynx-js/react-rsbuild-plugin": "workspace:*",
1717
"@lynx-js/rspeedy": "workspace:*",
18-
"@testing-library/jest-dom": "^6.8.0"
18+
"@testing-library/jest-dom": "^6.9.0"
1919
}
2020
}

packages/testing-library/testing-environment/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@
4949
"scripts": {
5050
"api-extractor": "api-extractor run --verbose",
5151
"build": "rslib build",
52-
"dev": "rslib build --watch"
52+
"dev": "rslib build --watch",
53+
"test": "vitest"
5354
},
5455
"devDependencies": {
55-
"@testing-library/jest-dom": "^6.8.0",
56+
"@testing-library/jest-dom": "^6.9.0",
5657
"@types/jsdom": "^21.1.7",
5758
"rsbuild-plugin-publint": "0.3.3"
5859
}

packages/testing-library/testing-environment/src/env/vitest/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { builtinEnvironments } from 'vitest/environments';
1+
import { builtinEnvironments, Environment } from 'vitest/environments';
22
import { LynxTestingEnv } from '@lynx-js/testing-environment';
33
import { JSDOM } from 'jsdom';
44

@@ -13,14 +13,16 @@ const env = {
1313

1414
const lynxTestingEnv = new LynxTestingEnv(fakeGlobal.jsdom as JSDOM);
1515
global.lynxTestingEnv = lynxTestingEnv;
16+
global.Node = lynxTestingEnv.jsdom.window.Node;
1617

1718
return {
1819
teardown(global) {
1920
delete global.lynxTestingEnv;
2021
delete global.jsdom;
22+
delete global.Node;
2123
},
2224
};
2325
},
24-
};
26+
} satisfies Environment;
2527

2628
export default env;

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)