Skip to content

Commit

Permalink
unregister close with grace when cypress exit
Browse files Browse the repository at this point in the history
  • Loading branch information
JacopoPatroclo committed Feb 22, 2024
1 parent 83a4c34 commit c907243
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN pnpm run build
FROM base
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
COPY --from=build /app/public/dist /app/public/dist

EXPOSE 3000
CMD [ "node", "dist/index.js" ]
17 changes: 8 additions & 9 deletions scripts/e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ execSync('pnpm build', { shell: true, stdio: 'inherit', env: process.env });
// Start the dev server
const devServer = exec('pnpm start', {
shell: true,
stdio: 'pipe',
stdio: 'inherit',
env: process.env,
});

devServer.stdout.pipe(process.stdout);
devServer.stderr.pipe(process.stderr);

// Wait for the dev server to be ready
await new Promise((resolve) => {
devServer.stdout.on('data', (data) => {
Expand All @@ -40,7 +37,7 @@ await new Promise((resolve) => {
// Run the e2e tests
const cypress = exec(`pnpm cypress ${watch ? 'open' : 'run'}`, {
shell: true,
stdio: 'pipe',
stdio: 'inherit',
env: process.env,
});

Expand All @@ -57,14 +54,16 @@ const timeout = setTimeout(
10 * 60 * 1000,
);

cypress.on('exit', () => {
// Stop the dev server
const clgListener = closeWithGrace({ delay: 500 }, () => {
cypress.kill();
devServer.kill();
clearTimeout(timeout);
});

closeWithGrace({ delay: 500 }, () => {
cypress.kill();
cypress.on('exit', (code) => {
console.log('Tests have finished with code ' + code);
// Stop the dev server
devServer.kill();
clearTimeout(timeout);
clgListener.uninstall();
});

0 comments on commit c907243

Please sign in to comment.