-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Problems with Relative Paths and Tests #175
Comments
Could you please post a few lines of your code? Related: #32 |
I hit the exact same issue with AVA and the config module. The working dir needs to be the directory where I launch test my process, not where the test file lives. |
@MarkHerhold Read #32 for context of why it's like it is. I'm surprised the |
@sindresorhus OK, that is fine. This is a major turn-off in terms of adoption of AVA. (#222 does not help either). I looks like the config module lets me define an environment variable called |
Currently, the best workaround for achieving the behavior you desire is:
At the top of every test: process.cwd(process.env.NODE_CONFIG_DIR); @sindresorhus @vdemedes - Do we want to add a flag or environment variable to address this? |
You mean to change the effective working directory of the test files? I think generally code should walk up the directory tree looking for the file it wants, or otherwise resolve relative to the Closing this now given the lack of discussion over the past three months. |
I ran into this same issue just now. In my mocha tests I always have a mocha.opts I wish there was a way to solve this, so that I could just run |
I suppose in the spirit of being able to just run On the other hand, that already doesn't work cause babel and |
Made this for now if anyone else runs into this issue.. https://www.npmjs.com/package/ava-config I can also rename the pkg if |
|
It might be good to make the same request of the community that other projects do. Save the |
Yup. Maybe mention it somewhere in the readme. |
I am using the config module to load configuration files in my Node app.
config looks for a dir called
./config
relative to the current working dir.When running tests via AVA, the current working directory is the location of the tests. This causes config to look in the wrong place for the
./config
dir. (I think this is due to the way AVA spawns processes. )To work around this I use an environment variable recognized by config to change the
./config
dir location when running tests:This is pretty teampramental, though - some test files are nested differently to others. What's more, some modules look for files relative to
process.cwd()
by default. In some cases, I can configure that but I think it is going to be very tedious to do.How should I work around this if I want to use AVA?
The text was updated successfully, but these errors were encountered: