Skip to content

Commit 0f5e93a

Browse files
committed
fix(integ-tests): tests need to mved before they can be run
For historical reasons of working with Jest 27 or lower, we needed to `mv` the `integ-tests` out of an install directory where they would be left by an `npm install`. The reason was that Jest 27 or lower would always ignore all `node_modules` direcotries, and so could not be configured to run tests from an install location. Since we are on Jest 29, we can now lift this limitation with the right configuration options. We can run the tests directly from the `node_modules` directory and don't have to fiddle around with moving files anymore.
1 parent 4068210 commit 0f5e93a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ const path = require('path');
22

33
const rootDir = path.resolve(__dirname, '..', 'tests', process.env.TEST_SUITE_NAME);
44

5-
if (rootDir.includes('node_modules')) {
6-
// Jest < 28 under no circumstances supports loading test if there's node_modules anywhere in the path,
7-
// and Jest >= 28 requires a newer TypeScript version than the one we support.
8-
throw new Error(`This package must not be 'npm install'ed (found node_modules in dir: ${rootDir})`);
9-
}
10-
115
module.exports = {
126
rootDir,
137
testMatch: [`**/*.integtest.js`],
@@ -23,5 +17,13 @@ module.exports = {
2317
reporters: [
2418
"default",
2519
["jest-junit", { suiteName: "jest tests", outputDirectory: "coverage" }]
26-
]
20+
],
21+
22+
// Both of the following things are necessary to discover test files that are
23+
// potentially installed into `node_modules`.
24+
testPathIgnorePatterns: [],
25+
haste: {
26+
// Necessary to include files in 'node_modules' where we may be installed.
27+
retainAllFiles: true,
28+
},
2729
};

projenrc/cdk-cli-integ-tests.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ export class CdkCliIntegTestsWorkflow extends Component {
376376
name: 'Download and install the test artifact',
377377
run: [
378378
'npm install @aws-cdk-testing/cli-integ',
379-
// Move the installed files to the current directory, because as
380-
// currently configured the tests won't run from an installed
381-
// node_modules directory.
382-
'mv ./node_modules/@aws-cdk-testing/cli-integ/* .',
383379
].join('\n'),
384380
},
385381
{
@@ -397,7 +393,7 @@ export class CdkCliIntegTestsWorkflow extends Component {
397393
{
398394
name: 'Run the test suite: ${{ matrix.suite }}',
399395
run: [
400-
`bin/run-suite${maxWorkersArg} --use-cli-release=\${{ steps.versions.outputs.cli_version }} --framework-version=\${{ steps.versions.outputs.lib_version }} \${{ matrix.suite }}`,
396+
`npx run-suite${maxWorkersArg} --use-cli-release=\${{ steps.versions.outputs.cli_version }} --framework-version=\${{ steps.versions.outputs.lib_version }} \${{ matrix.suite }}`,
401397
].join('\n'),
402398
env: {
403399
JSII_SILENCE_WARNING_DEPRECATED_NODE_VERSION: 'true',

0 commit comments

Comments
 (0)