Skip to content

Commit 3866213

Browse files
authored
chore: allow opt-out of test.concurrent in integ tests (#19402)
The `test.concurrent` feature of `jest` immediately executes the test code in order to obtain a `Promise` that is checked as part of the test run. This means that the test handler code runs whether the test is included or not in the assessment, as controlled by the `-t` flag of jest. In order to allow integration tests to selectively run only a subset of the tests, we must hence not use `test.concurrent`, or else all test handlers run fully, leading to unwanted side effects. This is needed in order to be able to complete cdklabs/cdk-ops#1922. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e63a03d commit 3866213

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

packages/aws-cdk/test/integ/cli/cli.integtest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { retry, sleep } from '../helpers/aws';
55
import { cloneDirectory, MAJOR_VERSION, shell, withDefaultFixture } from '../helpers/cdk';
66
import { integTest } from '../helpers/test-helpers';
77

8-
jest.setTimeout(600 * 1000);
8+
jest.setTimeout(600_000);
99

1010
integTest('VPC Lookup', withDefaultFixture(async (fixture) => {
1111
fixture.log('Making sure we are clean before starting.');

packages/aws-cdk/test/integ/helpers/test-helpers.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export function integTest(
1616
) {
1717

1818
// Integ tests can run concurrently, and are responsible for blocking themselves if they cannot.
19-
const runner = shouldSkip(name) ? test.skip : test.concurrent;
19+
// Because `test.concurrent` executes the test code immediately (to obtain a promise), we allow
20+
// setting the `JEST_TEST_CONCURRENT` environment variable to 'false' in order to use `test`
21+
// instead of `test.concurrent` (this is necessary when specifying a test pattern to verify).
22+
const testKind = process.env.JEST_TEST_CONCURRENT === 'false' ? test : test.concurrent;
23+
const runner = shouldSkip(name) ? testKind.skip : testKind;
2024

2125
runner(name, async () => {
2226
const output = new MemoryStream();
@@ -44,4 +48,4 @@ export function integTest(
4448

4549
function shouldSkip(testName: string) {
4650
return SKIP_TESTS.includes(testName);
47-
}
51+
}

packages/aws-cdk/tsconfig.json

+22-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,33 @@
1515
"resolveJsonModule": true,
1616
"composite": true,
1717
"incremental": true
18-
},
18+
},
1919
"include": [
2020
"**/*.ts",
2121
"**/*.d.ts",
2222
"lib/init-templates/**/add-project.hook.ts"
2323
],
2424
"exclude": [
2525
"lib/init-templates/**/typescript/**/*.ts"
26-
]
26+
],
27+
"references": [
28+
{
29+
"path": "../@aws-cdk/cloud-assembly-schema"
30+
},
31+
{
32+
"path": "../@aws-cdk/cloudformation-diff"
33+
},
34+
{
35+
"path": "../@aws-cdk/core"
36+
},
37+
{
38+
"path": "../@aws-cdk/cx-api"
39+
},
40+
{
41+
"path": "../@aws-cdk/region-info"
42+
},
43+
{
44+
"path": "../cdk-assets"
45+
},
46+
],
2747
}
28-

0 commit comments

Comments
 (0)