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.
importFrom
is an array of IPackageMock classes, to import custom mocks, such as from octo-aws-cdk package - OctoAwsCdkPackageMock.mocks
is an array of objects, to override the default factories.- Use
metadata?: { [key: string]: string }
to identify the factory being mocked. - Use
type: Constructable<T> | string
to identify the class being mocked. - Use
value: T
to provide the mocked value.
- Use
optionaloptions: TestContainerOptions
Options to configure TestContainer.
factoryTimeoutInMs?: number
is to override the default container timeout.
Returns Promise<void>
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 yourafterAll()
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.