TestContainer
Index
Constructors
Methods
Constructors
constructor
- Returns TestContainer
Methods
staticcreate
- The - TestContainer.create()method allows you to mock factories.- Parameters- subjects: TestContainerSubjects- The subjects being mocked. - mocksis an array of objects, to override the default factories.- Use metadata?: { [key: string]: string }to identify the factory being mocked.
- Use type: Constructable<T> | stringto identify the class being mocked.
- Use value: Tto provide the mocked value.
 
- Use 
 
- optionaloptions: TestContainerOptions- Options to configure TestContainer. - factoryTimeoutInMs?: numberis to override the default container timeout.
 
 - Returns Promise<Container>
staticreset
- The - TestContainer.reset()method will completely destroy all factories from the Container. Because the entire Container is destroyed, and not just the mocks, it must always be called in your- afterAll()block.- Returns Promise<void>
The TestContainer class is an isolated Container for tests.
A test framework like Jest, supports parallel test executions in different cores of the machine. Each test is a single test file, whose
it()blocks are executed serially.TestContainer is created with testing framework's parallel execution in mind. A TestContainer should be created in the
beforeAll()block of your test, which modifies the Container for the duration of the test. This TestContainer does not affect other tests in parallel since they are on a separate machine core. Once tests are done executing, theafterAll()block cleans up the Container.Functions/Container