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

ava incorrectly ignores test files when the project itself is contained in node_modules directory #1173

Closed
gajus opened this issue Jan 7, 2017 · 7 comments · Fixed by #2103
Labels
bug current functionality does not work as desired scope:globbing

Comments

@gajus
Copy link

gajus commented Jan 7, 2017

Description

I have two projects:

Due to the nature of the projects (process.pwd() aware dependency resolution), it is not possible to link isomorphic-webpack-demo inside isomorphic-webpack. Therefore, I need to do:

git clone https://github.com/gajus/isomorphic-webpack
git clone https://github.com/gajus/isomorphic-webpack-demo
(cd ./isomorphic-webpack && npm install)
(cd ./isomorphic-webpack-demo && npm install)
rm -fr ./isomorphic-webpack-demo/node_modules/isomorphic-webpack
cp ./isomorphic-webpack ./isomorphic-webpack-demo/node_modules

The problem happens when I try to run ava inside of isomorphic-webpack, i.e.

cd ./isomorphic-webpack-demo/node_modules/isomorphic-webpack
npm run test

I am getting error:

  1 exception

  ✖ Couldn't find any files to test

My guess (without looking at the source code), is that ava detects that ./isomorphic-webpack-demo/node_modules/isomorphic-webpack/test path includes node_modules and therefore ignores this path.

Expected behaviour: ava should detect the immediate ./test directory and run the tests.

Environment

node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
ava --version
npm --version
Node.js v7.3.0
darwin 16.3.0
0.17.0
3.10.10
@gajus gajus changed the title ava incorrectly ignore test files when the project itself is contained in node_modules directory ava incorrectly ignores test files when the project itself is contained in node_modules directory Jan 7, 2017
@oskarmurand
Copy link

oskarmurand commented Jan 9, 2017

In 0.15.2 it works if you cd into the module that contains the tests and then do ../.bin/ava with all of the flas and path that you need.

@gajus
Copy link
Author

gajus commented Jan 9, 2017

In 0.15.2 it works if you cd into the module that contains the tests and then do ../.bin/ava with all of the flas and path that you need.

Assuming you mean something like ava ./test/**/*, yes that works. However, behaviour of ava should not change depend on the current directory of the project, i.e. ava should work just as well.

@novemberborn
Copy link
Member

novemberborn commented Jan 13, 2017

I think this is related to isaacs/node-glob#301.

When searching for test files, if we match a directory we search for nested *.js files. This ends up passing an absolute pattern to glob (via globby), but with relative ignore patterns.

Instead we should make the pattern relative to this.cwd.

See isaacs/node-glob#189 (comment) for more background into globs behavior.

@novemberborn novemberborn added bug current functionality does not work as desired good for beginner help wanted labels Jan 13, 2017
@yatharthx
Copy link
Contributor

@novemberborn Do we need to work upon this bug?

@novemberborn
Copy link
Member

@yatharthk you can take this if you want, yes 😄

@Jolo510
Copy link

Jolo510 commented Jan 11, 2018

Hey @novemberborn, I new to open source and Ava. Would this be a good first bug to tackle?

@novemberborn
Copy link
Member

@Jolo510 actually I need to review the various globbing issues. I suggest you hold off until then. I think we may need a more comprehensive approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired scope:globbing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants