/
workflows.test.ts
41 lines (35 loc) · 1.09 KB
/
workflows.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// @@@SNIPSTART hello-world-project-template-ts-workflow-test
import { TestWorkflowEnvironment } from '@temporalio/testing';
import { before, describe, it } from 'mocha';
import { Worker } from '@temporalio/worker';
import { example } from '../workflows';
import * as activities from '../activities';
import assert from 'assert';
describe('Example workflow', () => {
let testEnv: TestWorkflowEnvironment;
before(async () => {
testEnv = await TestWorkflowEnvironment.createLocal();
});
after(async () => {
await testEnv?.teardown();
});
it('successfully completes the Workflow', async () => {
const { client, nativeConnection } = testEnv;
const taskQueue = 'test';
const worker = await Worker.create({
connection: nativeConnection,
taskQueue,
workflowsPath: require.resolve('../workflows'),
activities,
});
const result = await worker.runUntil(
client.workflow.execute(example, {
args: ['Temporal'],
workflowId: 'test',
taskQueue,
})
);
assert.equal(result, 'Hello, Temporal!');
});
});
// @@@SNIPEND