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

Can't find tests when project is in a path with parentheses #1081

Closed
luizribeiro opened this issue May 27, 2016 · 8 comments
Closed

Can't find tests when project is in a path with parentheses #1081

luizribeiro opened this issue May 27, 2016 · 8 comments

Comments

@luizribeiro
Copy link

I was trying to use Jest today from a Dropbox directory, under /Users/luizribeiro/Dropbox (Personal) on OSX. After struggling with Jest not finding any tests for a while, I realized that moving my project somewhere else that didn't have parentheses in the path fixed the problem.

Easy way to repro the issue is to:

$ mkdir -p "~/dir with (parentheses)/foo"
... setup project with the sum example from jest's docs
$ npm test
> foo@1.0.0 test /Users/luizribeiro/dir with (parentheses)/foo
> jest

Using Jest CLI v12.1.1, jasmine2
No tests found for "".
@mateuszsokola
Copy link

your configuration is invalid. Create a tests directory and create a valid test file there.

@cpojer
Copy link
Member

cpojer commented May 27, 2016

Thanks @mateuszsokola for helping out on issues! :)

@luizribeiro can you paste your config and your file system structure? It's possible that the default regex in testRegex might do something wonky on OS X :)

@luizribeiro
Copy link
Author

luizribeiro commented May 28, 2016

Hmm, I don't think it can be anything on my config. Just moving the project somewhere else and running npm test again fixes it.

Here's some more thorough repro steps:

$ mkdir -p "directory with (parentheses)/foo/"
$ cd "directory with (parentheses)/foo/"
$ cat > package.json <<EOL
heredoc> {
heredoc>   "scripts": {
heredoc>     "test": "jest"
heredoc>   }
heredoc> }
heredoc> EOL
$ cat > sum.js <<EOL
heredoc> function sum(a, b) {
heredoc>   return a + b;
heredoc> }
heredoc> module.exports = sum;
heredoc> EOL
$ mkdir __tests__
$ cat > __tests__/sum-test.js <<EOL
heredoc> jest.unmock('../sum');
heredoc> describe('sum', () => {
heredoc>   it('adds 1 + 2 to equal 3', () => {
heredoc>     const sum = require('../sum');
heredoc>     expect(sum(1, 2)).toBe(3);
heredoc>   });
heredoc> });
heredoc> EOL
$ npm install --save-dev jest-cli
$ npm test
> @ test /Users/luizribeiro/directory with (parentheses)/foo
> jest

Using Jest CLI v12.1.1, jasmine2
No tests found for "".
$  tree -I node_modules
.
├── __tests__
│   └── sum-test.js
├── package.json
└── sum.js

1 directory, 3 files
$ cd ../../
$ mv directory\ with\ \(parentheses\)/foo foo
$ cd foo
$ npm test

> @ test /Users/luizribeiro/foo
> jest

Using Jest CLI v12.1.1, jasmine2
 PASS  __tests__/sum-test.js (0.02s)
1 test passed (1 total in 1 test suite, run time 0.676s)

@luizribeiro
Copy link
Author

By the way, this issue is obviously not a big deal, since it's such a corner case :-)

The default testRegex is just __tests__/.*\.js$ as far as I can tell, so I'm not sure if that could be affecting it.. Maybe something about the crawler that builds the haste map? I didn't try using watchman instead to see what would happen, maybe I can give that a try tomorrow.

@cpojer
Copy link
Member

cpojer commented Jun 1, 2016

You could try patching #1057 and see if they are found at all and what filters them out :)

@kevinSuttle
Copy link

kevinSuttle commented Jul 28, 2016

Is there a doc describing the common setup regexes and how to configure them in jest?

__tests__/.*\.js$: default
\w+\/.*.test.js (or something): with component inside directory

Edit: here: https://facebook.github.io/jest/docs/api.html#testregex-string

@cpojer
Copy link
Member

cpojer commented Aug 16, 2016

This is fixed in the latest test release (can be installed through jest@test) and will be fixed in the next release, Jest 15.

@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 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants