Skip to content

Commit

Permalink
fix(web): ensure unique port is used for file server tests (#15952)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Mar 29, 2023
1 parent 986a8c4 commit 18c8e70
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions e2e/web/src/file-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,32 @@ describe('file-server', () => {
`generate @nrwl/web:static-config --buildTarget=${reactAppName}:build --targetName=custom-serve-static --no-interactive`
);

const port = 6200;

const ngServe = await runCommandUntil(
`serve-static ${ngAppName}`,
`serve-static ${ngAppName} --port=${port}`,
(output) => {
return output.indexOf('localhost:4200') > -1;
return output.indexOf(`localhost:${port}`) > -1;
}
);

try {
await promisifiedTreeKill(ngServe.pid, 'SIGKILL');
await killPorts(4200);
await killPorts(port);
} catch {
// ignore
}

const reactServe = await runCommandUntil(
`custom-serve-static ${reactAppName}`,
`custom-serve-static ${reactAppName} --port=${port + 1}`,
(output) => {
return output.indexOf('localhost:4200') > -1;
return output.indexOf(`localhost:${port + 1}`) > -1;
}
);

try {
await promisifiedTreeKill(reactServe.pid, 'SIGKILL');
await killPorts(4200);
await killPorts(port + 1);
} catch {
// ignore
}
Expand Down

0 comments on commit 18c8e70

Please sign in to comment.