From 2bea7bcf514f325f52d471eeb939e963117ef357 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Fri, 18 Mar 2022 16:35:32 +0100 Subject: [PATCH] chore(cli): integ test filtering is broken Turns out that Jest's `test.concurrent()` does not play well when running `jest -t TESTNAME`: jest will actually start all tests, not just the one you were trying to run. Reported here: https://github.com/facebook/jest/issues/12588 We used to have something to opt-out of concurrent running: we have to flip that around, and opt in to concurrent running only for the canary and pipeline tests, where we *know* for a fact we're not filtering. --- .../aws-cdk/test/integ/helpers/test-helpers.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/test/integ/helpers/test-helpers.ts b/packages/aws-cdk/test/integ/helpers/test-helpers.ts index 8681e16c16499..e74d7d000a777 100644 --- a/packages/aws-cdk/test/integ/helpers/test-helpers.ts +++ b/packages/aws-cdk/test/integ/helpers/test-helpers.ts @@ -15,14 +15,18 @@ export function integTest( timeoutMillis?: number, ) { - // Integ tests can run concurrently, and are responsible for blocking themselves if they cannot. - // Because `test.concurrent` executes the test code immediately (to obtain a promise), we allow - // setting the `JEST_TEST_CONCURRENT` environment variable to 'false' in order to use `test` - // instead of `test.concurrent` (this is necessary when specifying a test pattern to verify). - const testKind = process.env.JEST_TEST_CONCURRENT === 'false' ? test : test.concurrent; + // Integ tests can run concurrently, and are responsible for blocking + // themselves if they cannot. Because `test.concurrent` executes the test + // code immediately, regardles of any `--testNamePattern`, this cannot be the + // default: test filtering simply does not work with `test.concurrent`. + // Instead, we make it opt-in only for the pipeline where we don't do any + // selection, but execute all tests unconditionally. + const testKind = process.env.JEST_TEST_CONCURRENT === 'true' ? test.concurrent : test; const runner = shouldSkip(name) ? testKind.skip : testKind; runner(name, async () => { + // eslint-disable-next-line no-console + console.log(`running test ${name} using ${runner.name}`); const output = new MemoryStream(); output.write('================================================================\n');