Skip to content

Commit 6c2ada0

Browse files
reduce changes
1 parent 6f321cd commit 6c2ada0

2 files changed

Lines changed: 33 additions & 39 deletions

File tree

CONTRIBUTING.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Working with Individual Packages](#working-with-individual-packages)
1414
- [Testing](#testing)
1515
- [Testing local changes to core](#testing-local-changes-to-core)
16+
- [Integration tests](#integration-tests)
1617
- [test-npm-init](#test-npm-init)
1718
- [Style Guide](#style-guide)
1819
- [Updating and pruning dependencies](#updating-and-pruning-dependencies)
@@ -44,7 +45,7 @@ However, we recommend using the [Active LTS](https://nodejs.org/en/about/previou
4445
for SDK development. For easier testing during development, you may want to use
4546
a version manager, such as [fnm](https://github.com/Schniz/fnm) or [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md).
4647

47-
1. To run integration tests, you will need a local Temporal server. The easiest way is using the
48+
1. To run tests, you will need access to a local Temporal server, e.g. using the
4849
[Temporal CLI's integrated dev server](https://github.com/temporalio/cli#start-the-server).
4950
2. Install the [Rust toolchain](https://rustup.rs/).
5051
3. Install [Protocol Buffers](https://github.com/protocolbuffers/protobuf/releases/).
@@ -133,20 +134,10 @@ described [here](https://doc.rust-lang.org/cargo/reference/overriding-dependenci
133134

134135
#### Integration tests
135136

136-
Integration tests require a running Temporal server. By default, tests will start an ephemeral
137-
server automatically using the Temporal CLI.
137+
In order to run integration tests:
138138

139-
To run tests against an existing server instead, set the `TEMPORAL_SERVICE_ADDRESS` environment variable:
140-
141-
```sh
142-
export TEMPORAL_SERVICE_ADDRESS=localhost:7233
143-
```
144-
145-
To skip integration tests entirely, set:
146-
147-
```sh
148-
export RUN_INTEGRATION_TESTS=false
149-
```
139+
1. Run the Temporal server, e.g. using the [Temporal CLI's integrated dev server](https://github.com/temporalio/cli#start-the-server)
140+
1. Export `RUN_INTEGRATION_TESTS=true`
150141

151142
#### test-npm-init
152143

packages/test/src/test-testenvironment.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import * as process from 'process';
22
import { TestFn } from 'ava';
33
import { v4 as uuid4 } from 'uuid';
44
import { WorkflowFailedError } from '@temporalio/client';
5-
import { bundleWorkflowCode, WorkflowBundleWithSourceMap } from '@temporalio/worker';
65
import { workflowInterceptorModules } from '@temporalio/testing';
7-
import { Worker, TestWorkflowEnvironment, testTimeSkipping } from './helpers';
6+
import { bundleWorkflowCode, WorkflowBundleWithSourceMap } from '@temporalio/worker';
87
import {
98
assertFromWorkflow,
109
asyncChildStarter,
@@ -13,15 +12,16 @@ import {
1312
unblockSignal,
1413
waitOnSignalWithTimeout,
1514
} from './workflows/testenv-test-workflows';
15+
import { Worker, TestWorkflowEnvironment, testTimeSkipping as anyTestTimeSkipping } from './helpers';
1616

1717
interface Context {
1818
testEnv: TestWorkflowEnvironment;
1919
bundle: WorkflowBundleWithSourceMap;
2020
}
2121

22-
const test_ = testTimeSkipping as TestFn<Context>;
22+
const testTimeSkipping = anyTestTimeSkipping as TestFn<Context>;
2323

24-
test_.before(async (t) => {
24+
testTimeSkipping.before(async (t) => {
2525
t.context = {
2626
testEnv: await TestWorkflowEnvironment.createTimeSkipping(),
2727
bundle: await bundleWorkflowCode({
@@ -31,28 +31,31 @@ test_.before(async (t) => {
3131
};
3232
});
3333

34-
test_.after.always(async (t) => {
34+
testTimeSkipping.after.always(async (t) => {
3535
await t.context.testEnv?.teardown();
3636
});
3737

38-
test_.serial('TestEnvironment sets up test server and is able to run a Workflow with time skipping', async (t) => {
39-
const { client, nativeConnection } = t.context.testEnv;
40-
const worker = await Worker.create({
41-
connection: nativeConnection,
42-
taskQueue: 'test',
43-
workflowBundle: t.context.bundle,
44-
});
45-
await worker.runUntil(
46-
client.workflow.execute(sleep, {
47-
workflowId: uuid4(),
38+
testTimeSkipping.serial(
39+
'TestEnvironment sets up test server and is able to run a Workflow with time skipping',
40+
async (t) => {
41+
const { client, nativeConnection } = t.context.testEnv;
42+
const worker = await Worker.create({
43+
connection: nativeConnection,
4844
taskQueue: 'test',
49-
args: [1_000_000],
50-
})
51-
);
52-
t.pass();
53-
});
45+
workflowBundle: t.context.bundle,
46+
});
47+
await worker.runUntil(
48+
client.workflow.execute(sleep, {
49+
workflowId: uuid4(),
50+
taskQueue: 'test',
51+
args: [1_000_000],
52+
})
53+
);
54+
t.pass();
55+
}
56+
);
5457

55-
test_.serial('TestEnvironment can toggle between normal and skipped time', async (t) => {
58+
testTimeSkipping.serial('TestEnvironment can toggle between normal and skipped time', async (t) => {
5659
const { client, nativeConnection } = t.context.testEnv;
5760

5861
const worker = await Worker.create({
@@ -78,7 +81,7 @@ test_.serial('TestEnvironment can toggle between normal and skipped time', async
7881
t.pass();
7982
});
8083

81-
test_.serial('TestEnvironment sleep can be used to delay activity completion', async (t) => {
84+
testTimeSkipping.serial('TestEnvironment sleep can be used to delay activity completion', async (t) => {
8285
const { client, nativeConnection, sleep } = t.context.testEnv;
8386

8487
const worker = await Worker.create({
@@ -107,7 +110,7 @@ test_.serial('TestEnvironment sleep can be used to delay activity completion', a
107110
t.pass();
108111
});
109112

110-
test_.serial('TestEnvironment sleep can be used to delay sending a signal', async (t) => {
113+
testTimeSkipping.serial('TestEnvironment sleep can be used to delay sending a signal', async (t) => {
111114
const { client, nativeConnection, sleep } = t.context.testEnv;
112115

113116
const worker = await Worker.create({
@@ -128,7 +131,7 @@ test_.serial('TestEnvironment sleep can be used to delay sending a signal', asyn
128131
t.pass();
129132
});
130133

131-
test_.serial('Workflow code can run assertions', async (t) => {
134+
testTimeSkipping.serial('Workflow code can run assertions', async (t) => {
132135
const { client, nativeConnection } = t.context.testEnv;
133136

134137
const worker = await Worker.create({
@@ -150,7 +153,7 @@ test_.serial('Workflow code can run assertions', async (t) => {
150153
t.is(err?.cause?.message, 'Expected values to be strictly equal:\n\n6 !== 7\n');
151154
});
152155

153-
test_.serial('ABNADONED child timer can be fast-forwarded', async (t) => {
156+
testTimeSkipping.serial('ABNADONED child timer can be fast-forwarded', async (t) => {
154157
const { client, nativeConnection } = t.context.testEnv;
155158

156159
const worker = await Worker.create({

0 commit comments

Comments
 (0)