Skip to content

Commit f065877

Browse files
rix0rrrgithub-actions
andauthored
fix(integ-tests): tests need to mved before they can be run (#439)
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. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent fb027a2 commit f065877

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

.github/workflows/integ.yml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
@@ -3,12 +3,6 @@ const os = require('os');
33

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

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

3032
/**

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)