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

findRelatedTests is case-insensitive on Windows #8622

Closed
mbelsky opened this issue Jun 29, 2019 · 4 comments
Closed

findRelatedTests is case-insensitive on Windows #8622

mbelsky opened this issue Jun 29, 2019 · 4 comments

Comments

@mbelsky
Copy link
Contributor

mbelsky commented Jun 29, 2019

🐛 Bug Report

To Reproduce

Steps to reproduce the behavior:

  • Clone
  • Replace return undefined; with return -1; in problems/001-sum.js
  • git add .
  • npx jest --findRelatedTests Problems/001-sum.js. Note: the real path to the file is problems/001-sum.js - the first letter is lowercased
Output:
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in C:\Users\publi\js\js-problems.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: Problems\\001-sum.js - 0 matches

Expected behavior

 FAIL  problems/__tests__/001.js
  × Тестирование задачи "001-sum" (1008ms)

● Тестирование задачи "001-sum"

expect(received).toBe(expected) // Object.is equality

Expected: 1
Received: -1

  2 | 
  3 | test('Тестирование задачи "001-sum"', () => {
> 4 |     expect(sum(-100)).toBe(1);
    |                       ^
  5 |     expect(sum(0)).toBe(1);
  6 |     expect(sum(1)).toBe(1);
  7 |     expect(sum(2)).toBe(3);

  at Object.toBe (problems/__tests__/001.js:4:23)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 2.226s
Ran all test suites related to files matching /Problems\001-sum.js/i.

Link to repo

npx envinfo --preset jest results

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
  Binaries:
    Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
@mbelsky
Copy link
Contributor Author

mbelsky commented Jul 4, 2019

It may look so minor because all you need is write a path correctly. However I have 100% repro when commit through VSCode's SCM. It triggers pre-commit husky hook which generate lint-staged tasks with [ 'c:\\Users\\publi\\js\\js-problems\\problems\\001-sum.js' ] fileList (lower-case 'c') and jest cannot find this file.

Is it possible to fix that issue? I've tried to find a piece of code that do that, but without success.

@mbelsky
Copy link
Contributor Author

mbelsky commented Jul 12, 2019

I've found an alternative solution for my case. Since v9.2.0 lint-staged has --relative option and that helps to run right tests.

@mbelsky
Copy link
Contributor Author

mbelsky commented May 21, 2020

Fixed in #8961

@mbelsky mbelsky closed this as completed May 21, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant