Skip to content

Commit a897f99

Browse files
authored
tests: silence require(esm) warnings for Node 22.12 (#12545)
Node 22.12 enables `require(esm)` by default. As part of this, the `module-sync` export condition gets used whereas in 22.11 that export condition gets ignored. We've setup out package.json exports for `react-router` to use the `module-sync` condition to point to the ESM version so that no matter where you get `react-router` from you always get the same copy. That's a good thing! So in 22.11, you get a (duplicate) CJS version of `react-router` and in 22.12 you get a (deduplicated) ESM version of `react-router`. This is all intended behavior, but Node shipped this new default while still logging warnings for `require(esm)` to stderr. Since many of our integration tests check stderr for warnings, those started failing. Again, everything is working correctly (and better than in 22.11) so this commit simply silences the experimental warnings from Node so that our integration tests don't mistake expected Node warnings for unexpected warnings/errors.
1 parent c9487e6 commit a897f99

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

integration/helpers/create-fixture.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export async function createAppFixture(fixture: Fixture, mode?: ServerMode) {
217217
],
218218
{
219219
env: {
220+
...process.env,
220221
NODE_ENV: mode || "production",
221222
PORT: port.toFixed(0),
222223
},

integration/playwright.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { PlaywrightTestConfig } from "@playwright/test";
22
import { devices } from "@playwright/test";
33

4+
// silence expected warnings in Node 22.12 about `require(esm)`
5+
// when it implicitly uses `react-router`'s `module-sync` export condition
6+
process.env.NODE_OPTIONS =
7+
(process.env.NODE_OPTIONS ?? "") + ` --no-warnings=ExperimentalWarning`;
8+
49
const config: PlaywrightTestConfig = {
510
testDir: ".",
611
testMatch: ["**/*-test.ts"],

0 commit comments

Comments
 (0)