Skip to content

Commit ee8bbe1

Browse files
alan-agius4Keen Yee Liau
authored and
Keen Yee Liau
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 (cherry picked from commit bf599e4)
1 parent e0f12e1 commit ee8bbe1

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

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

Lines changed: 24 additions & 18 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,13 +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-
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
35-
}
32+
const { stderr } = await ng('build', '--verbose', '--no-vendor-chunk', '--no-progress');
33+
const outFile = 'dist/test-project/main.js';
3634

37-
const outFile = 'dist/test-project/main.js';
38-
await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
35+
if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy -> .+tslib-1/.test(stderr)) {
3936
await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js');
4037
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');
4147
}

0 commit comments

Comments
 (0)