feat(test-setup): restructure to synchronous builder

The previous pattern used async methods for the builder pattern,
which were hideous to use when chained multiple times.

This extracts the builder into a separate class
and uses normal functions in the builder.
These queue async functions in arrays, which are executed
at the correct time, when the new async `build` function is called.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2022-01-06 21:41:36 +01:00
parent 8f1aeab934
commit d1dbd1bb22
13 changed files with 156 additions and 84 deletions

View file

@ -7,7 +7,7 @@ import request from 'supertest';
import { LoginDto } from '../../src/identity/local/login.dto';
import { RegisterDto } from '../../src/identity/local/register.dto';
import { TestSetup } from '../test-setup';
import { TestSetup, TestSetupBuilder } from '../test-setup';
describe('Register and Login', () => {
let testSetup: TestSetup;
@ -17,7 +17,7 @@ describe('Register and Login', () => {
const PASSWORD = 'secure';
beforeEach(async () => {
testSetup = await TestSetup.create();
testSetup = await TestSetupBuilder.create().build();
await testSetup.app.init();
});