Closed
Description
Currently the cwd is the directory you execute ava
in, but ava
can be executed from any upper level in the project and will search down for test files, so the cwd is pretty arbitrary and useless. I want to make the cwd actually useful.
There are two options:
- Change cwd to root of the project. (This is what gulp/grunt does)
- Change cwd to the directory of the currently running test file. (This is what I personally prefer)
The reason I prefer the latter is that we run the test files hence IMHO the cwd is where we run it. It's like we would do: cd tests && node test.js
.
Currently you have to do this to be able to load a read a test relative file:
var path = require('path');
var fs = require('fs');
fs.readFileSync(path.join(__dirname, 'foo.json'));
If we changed process.cwd()
to the currently running test directory we could instead just do:
var fs = require('fs');
fs.readFileSync('foo.json');
Thoughts? Anything I'm missing?