Home » Javascript » Chai same test case multiple files

Chai same test case multiple files

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am trying to run test cases in my Node.js application using the Chai framework.

I have a test case which is used in 10 different files. The test is the same, so it is basically duplicated code in multiple files. The test looks something like:

  it('common test', (done) => {
     run_some_method((e, r) => {
        expect(e).to.be.null;
        .....
     });
  });

Is there a way to write this in one place and include it in the 10 files?

Answers: