1

According to Ava's documentation, I should create a file named test.js at the root of my project. But having a single file for my tests seems like a recipe for maintenance nightmares. Thus, I want to split my tests into multiple files, all within a folder named tests and somehow run them from my test.js file.

For example, let's say we have a test file named ./tests/basic-tests.js with this code:

    import test from ava;
    import {Calculator} from calculator;

    test('it calculates',t =>{
      //Some test here
    });

And an another file named ./tests/burn_it_down.js:

    import test from ava;
    import {SethRollins} from wwe;

    test('Burned it Down',t =>{
      //Another tests here
    });

I want test.js to somehow run both the tests in ./tests/basic-tests.js and in ./tests/burn_it_down.js. Is there a way to do that?

Max
  • 1,054
  • 1
  • 12
  • 20
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164

1 Answers1

2

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"
  }
}
Mark Wubben
  • 3,329
  • 1
  • 19
  • 16
  • 3
    I got an error saying `The 'files' configuration must be an array containing glob patterns`. So I changed it to: `"files": ["./tests/*.js"]` – dcts Mar 13 '20 at 00:28