Skip to content

Commit bf599e4

Browse files
committed
ci: fix dedupe-duplicate-modules flakes
Following #17973, which we emitted the stderr when this test failed on CI. We see that the resolved module order sometimes changes, which is totally fine because of the async nature of the operation. https://circleci.com/gh/angular/angular-cli/167318#tests/containers/5 ``` [DedupeModuleResolvePlugin]: /tmp/angular-cli-e2e-i03vMQ/test-project/node_modules/tslib-1 -> /tmp/angular-cli-e2e-i03vMQ/test-project/node_modules/tslib-1-copy ``` With this change we handle both cases which should eliminate the flakes
1 parent cbf0db4 commit bf599e4

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ import { updateJsonFile } from '../../utils/project';
44
import { expectToFail } from '../../utils/utils';
55

66
export default async function () {
7-
// Force duplicate modules
8-
await updateJsonFile('package.json', json => {
9-
json.dependencies = {
10-
...json.dependencies,
11-
'tslib': '2.0.0',
12-
'tslib-1': 'npm:[email protected]',
13-
'tslib-1-copy': 'npm:[email protected]',
14-
};
15-
});
7+
// Force duplicate modules
8+
await updateJsonFile('package.json', json => {
9+
json.dependencies = {
10+
...json.dependencies,
11+
'tslib': '2.0.0',
12+
'tslib-1': 'npm:[email protected]',
13+
'tslib-1-copy': 'npm:[email protected]',
14+
};
15+
});
1616

17-
await silentNpm('install');
17+
await silentNpm('install');
1818

19-
await writeFile('./src/main.ts',
20-
`
19+
await writeFile('./src/main.ts',
20+
`
2121
import { __assign as __assign_0 } from 'tslib';
2222
import { __assign as __assign_1 } from 'tslib-1';
2323
import { __assign as __assign_2 } from 'tslib-1-copy';
@@ -29,14 +29,19 @@ export default async function () {
2929
})
3030
`);
3131

32-
const { stderr } = await ng('build', '--verbose', '--no-vendor-chunk', '--no-progress');
33-
if (!/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy -> .+tslib-1/.test(stderr)) {
34-
console.error(`\n\n\n${stderr}\n\n\n`);
35-
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
36-
}
32+
const { stderr } = await ng('build', '--verbose', '--no-vendor-chunk', '--no-progress');
33+
const outFile = 'dist/test-project/main.js';
3734

38-
const outFile = 'dist/test-project/main.js';
39-
await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
35+
if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy -> .+tslib-1/.test(stderr)) {
4036
await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js');
4137
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'));
38+
} else if (/\[DedupeModuleResolvePlugin\]:.+tslib-1 -> .+tslib-1-copy/.test(stderr)) {
39+
await expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js');
40+
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js'));
41+
} else {
42+
console.error(`\n\n\n${stderr}\n\n\n`);
43+
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
44+
}
45+
46+
await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
4247
}

0 commit comments

Comments
 (0)