Skip to content

Commit

Permalink
test: remove hardcoded worker chunk id
Browse files Browse the repository at this point in the history
This commit changes how we retrieve the worker chunk Id. Prior to this change we hard coded the value, now we get it by reading the file names on disk.
  • Loading branch information
alan-agius4 authored and clydin committed Aug 26, 2022
1 parent 5172bd3 commit 2925f06
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/legacy-cli/e2e/tests/build/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import { readdir } from 'fs/promises';
import { expectFileToExist, expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs';
import { ng } from '../../utils/process';

Expand All @@ -26,7 +27,8 @@ export default async function () {
await expectFileToMatch('dist/test-project/main.js', 'src_app_app_worker_ts');

await ng('build', '--output-hashing=none');
const chunkId = '151';

const chunkId = await getWorkerChunkId();
await expectFileToExist(`dist/test-project/${chunkId}.js`);
await expectFileToMatch('dist/test-project/main.js', chunkId);

Expand All @@ -53,3 +55,14 @@ export default async function () {

await ng('e2e');
}

async function getWorkerChunkId(): Promise<string> {
const files = await readdir('dist/test-project');
const fileName = files.find((f) => /^\d{3}\.js$/.test(f));

if (!fileName) {
throw new Error('Cannot determine worker chunk Id.');
}

return fileName.substring(0, 3);
}

0 comments on commit 2925f06

Please sign in to comment.