Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Node 23 normalizes paths in a way that results in Jest finding no tests #15348

Open
steveluscher opened this issue Oct 18, 2024 · 1 comment

Comments

@steveluscher
Copy link

steveluscher commented Oct 18, 2024

Version

main branch

Steps to reproduce

yarn jest-jasmine-ci e2e/__tests__/jestChangedFiles.test.ts

Expected behavior

Tests pass.

Actual behavior

includePaths ends up having '../jest-changed-files-test-dir' under Node 23 instead of '.' under Node <=22. This causes git to freak out because the directory is ‘outside the repository.’

/home/sol/src/jest/e2e/__tests__/jestChangedFiles.test.ts

  ● gets changed files for git

    Command failed with exit code 128: git diff --cached --name-only -- nested-dir nested-dir/second-nested-dir ../jest-changed-files-test-dir
    fatal: ../jest-changed-files-test-dir: '../jest-changed-files-test-dir' is outside repository at '/tmp/jest-changed-files-test-dir'

      207 |   ].map(filename => path.resolve(DIR, filename));
      208 |   console.log(roots);
    > 209 |   let {changedFiles: files} = await getChangedFilesForRoots(roots, {});
          |                               ^
      210 |   expect([...files].map(filePath => path.basename(filePath)).sort()).toEqual([
      211 |     'file1.txt',
      212 |     'file2.txt',

      at makeError (node_modules/execa/lib/error.js:60:11)
          at async Promise.all (index 0)
          at async Promise.all (index 0)
      at Object.<anonymous> (e2e/__tests__/jestChangedFiles.test.ts:209:31)

Additional context

This appears to be because of a bug in Node 23, but that's no reason not to try to strip the trailing slash in Jest, defensively. nodejs/node#55448

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (64) x64 AMD EPYC 7502P 32-Core Processor
  Binaries:
    Node: 23.0.0 - ~/n/bin/node
    Yarn: 3.8.5 - ~/.local/share/pnpm/yarn
    npm: 10.9.0 - ~/n/bin/npm
  npmPackages:
    jest: workspace:* => 30.0.0-alpha.6
@steveluscher
Copy link
Author

Looks like this has been reverted in Node. nodejs/node#55414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant