问题
As ava documentation says I should create a file named test.js
to my root's project. But having a single file for my tests seems a recipe for maintenance nightmares. Thus I want to split my tests into multiple files into a folder named tests
and somehow run them from test.js
file.
For example let us suppose we have a test named ./tests/basic-tests.js
and has this code:
import test from ava;
import {Calculator} from calculator;
test('it calculates',t =>{
//Some test here
});
And have an another one in ./tests/burn_it_down.js
import test from ava;
import {SethRollins} from wwe;
test('Burned it Down',t =>{
//Another tests here
});
So I want in test.js somehow to run both the tests in ./tests/basic-tests.js
and in ./tests/burn_it_down.js
. Do you know how to do that?
回答1:
AVA works with multiple files, too. tests/
isn't in the default search pattern though (test/
is). Assuming you're configuring AVA through the package.json
file you can do:
{
"ava": {
"files": "./tests/*.js"
}
}
来源:https://stackoverflow.com/questions/53657737/ava-split-tests-into-multiple-files