0

I have following files

test1.ts
test2.ts
test3.ts
test4.ts
test5.ts

I want to start the tests at once with a unified before and after so that i start the application just once and run tests and close it after that

every test file has its own describe

skyboyer
  • 22,209
  • 7
  • 57
  • 64
FarFarAway
  • 1,017
  • 3
  • 14
  • 35
  • You can create new file module that creates server once, and then returns the same singleton server for further calls – iofjuupasli Jun 07 '19 at 09:00

1 Answers1

0

I was able to do this by adding a file to my test/ directory called setup.spec.ts that performs the setup & teardown using mochas before & after hooks. These hooks are run before/after any describe block in your other test files.

import {setupApp, teardownApp} from '../src/helpers/app';

before(async () => {
  await setupApp();
});

after(async () => {
  await teardownApp();
});
jpolley
  • 134
  • 11