Ava split tests Into multiple files

谁说胖子不能爱 提交于 2019-12-20 05:58:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!