Skip to content

Commit

Permalink
chore(cli): integ test filtering is broken (#19462)
Browse files Browse the repository at this point in the history
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: jestjs/jest#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.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Mar 21, 2022
1 parent 73c6a1b commit 8dd93a8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/aws-cdk/test/integ/helpers/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 8dd93a8

Please sign in to comment.