Skip to content

[Bug?]: pnp-esm.test.ts fails on node 22 #6267

Closed
@rluvaton

Description

@rluvaton

I'm wondering if it's node issue or yarn

Self-service

  • I'd be willing to implement a fix

Describe the bug

Seem like the test packages/acceptance-tests/pkg-tests-specs/sources/pnp-esm.test.ts is failing on node 22

To reproduce

run the test in node 22

Environment

System:
    OS: Linux 6.2 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (2) x64 AMD EPYC 7763 64-Core Processor
  Binaries:
    Node: 22.0.0 - /tmp/xfs-f68ecfb2/node
    Yarn: 4.2.1-dev - /tmp/xfs-f68ecfb2/yarn
    npm: 10.5.1 - ~/nvm/current/bin/npm

Additional context


  ● Plug'n'Play - ESM › it should resolve JSON modules with an import assertion

    Temporary fixture folder: /tmp/xfs-cc3b54c5/test

    expect(received).resolves.toMatchObject()

    Received promise rejected instead of resolved
    Rejected to value: [Error: Command failed: /usr/local/share/nvm/versions/node/v22.0.0/bin/node /workspaces/berry/packages/yarnpkg-cli/bundles/yarn.js node ./index.js
    file:///tmp/xfs-cc3b54c5/test/index.js:2
              import foo from './foo.json' assert { type: 'json' };
                                           ^^^^^^·
    SyntaxError: Unexpected identifier 'assert'
        at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
        at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
        at callTranslator (node:internal/modules/esm/loader:416:14)
        at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
        at async link (node:internal/modules/esm/module_job:88:21)·
    Node.js v22.0.0··
    ===== stdout:·
    ```
    ```·
    ===== stderr:·
    ```
    file:///tmp/xfs-cc3b54c5/test/index.js:2
              import foo from './foo.json' assert { type: 'json' };
                                           ^^^^^^·
    SyntaxError: Unexpected identifier 'assert'
        at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
        at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
        at callTranslator (node:internal/modules/esm/loader:416:14)
        at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
        at async link (node:internal/modules/esm/module_job:88:21)·
    Node.js v22.0.0
    ```·
    ]

      203 |       async ({path, run, source}) => {
      204 |         await expect(run(`install`)).resolves.toMatchObject({code: 0});
    > 205 |
          | ^
      206 |         await xfs.writeFilePromise(
      207 |           ppath.join(path, `index.js`),
      208 |           `import './foo';`,

      at expect (../../.yarn/cache/expect-npm-29.2.1-77e66f565d-9bc10fa9bf.zip/node_modules/expect/build/index.js:105:15)
      at pkg-tests-specs/sources/pnp-esm.test.ts:205:11
      at Object.<anonymous> (pkg-tests-core/sources/utils/tests.ts:671:11)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 2 skipped, 40 passed, 43 total
Snapshots:   0 total
Time:        42.47 s, estimated 43 s

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions