diff --git a/packages/@aws-cdk/integ-runner/lib/runner/integration-tests.ts b/packages/@aws-cdk/integ-runner/lib/runner/integration-tests.ts index 970dc1c4fd6f3..8da9d3ebaa47b 100644 --- a/packages/@aws-cdk/integ-runner/lib/runner/integration-tests.ts +++ b/packages/@aws-cdk/integ-runner/lib/runner/integration-tests.ts @@ -321,7 +321,11 @@ export class IntegrationTests { fileName, appCommand, })), - ); + ) + // Remove tests with duplicate names, giving precedence in lexicographic order + // Which ensures precedence of compiled .js files over their .ts source + .sort((a, b) => a.testName.localeCompare(b.testName)) + .filter((a, idx, allTests) => allTests.findIndex(b => (b.testName === a.testName)) === idx); return this.filterTests(discoveredTests, options.tests, options.exclude); } diff --git a/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts b/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts index 0057986775416..11c5af79756e5 100644 --- a/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts +++ b/packages/@aws-cdk/integ-runner/test/runner/integration-tests.test.ts @@ -114,4 +114,19 @@ describe('IntegrationTests Discovery', () => { }); }); }); + + describe('Same test file in JS and TS is only running JS', () => { + const cliOptions = { + language: ['javascript', 'typescript'], + }; + + test('find only JS files', async () => { + const integTests = await tests.fromCliOptions(cliOptions); + + expect(integTests.length).toEqual(3); + expect(integTests[0].fileName).toEqual(expect.stringMatching(new RegExp('^.*test1\\.js$'))); + expect(integTests[1].fileName).toEqual(expect.stringMatching(new RegExp('^.*test2\\.js$'))); + expect(integTests[2].fileName).toEqual(expect.stringMatching(new RegExp('^.*test3\\.js$'))); + }); + }); });