How to export describe/tests and reuse them in another test files in jest

Viewed 885

I have a test file that is too long and I want to divide it into several files when each file contains a test on a different domain. In addition I want to create one file that can run all the tests from all the files In the order I set for him. How do I export describes from the small files and import them into the general file Something like this:

gridTest.js:

export describe ("grid")

sanityTest.js:

import "grid" from "./gridTest"

grid ()

And so on ...

1 Answers

I used "require" function which causes the file to run. For example:

gridTest.js

//write tests and describes

sanityTest.js

describe('grid', () => {

  //This will run the entire gridTest.js file
  require('./gridTest);

})

Related