Hi,
I want to launch Temporal as part of a unit/integration testsuite setUp method in Typescript and stop it at the end of the testsuite. Let’s say I’m using the Mocha testing framework. Are there any code samples for this?
Or is it recommended to launch temporal via TestContainers or something like that?
The TypeScript SDK, as all other SDKs, comes with a testing package.
The testing package for TypeScript will automatically download, start, and stop a development server for you.
There are two different types of development servers:
One using temporal CLI’s dev server
One using the a pre-compiled, standalone version of Java SDK’s time skipping test server
The CLI based server is started with createLocal and is guaranteed to have the same behavior as the “real” Temporal server because its built from the same codebase. It uses an in memory database to avoid persisting state between test runs.
The time skipping server is started with createTimeSkipping and is an alternative, lightweight implementation of Temporal, use this server if you need to test workflows that take a long time as the server will automatically skip time when the workflow is “idle”.
See the dev guide for examples and the tests in the samples repo (there are more in there, I selected one that uses mocha):