Skip to content

Commit

Permalink
fix(testing): close cypress web server correctly on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 4, 2024
1 parent 8bde48f commit 20efc8f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/cypress/plugins/cypress-preset.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { workspaceRoot } from '@nx/devkit';
import { dirname, join, relative } from 'path';
import { existsSync, lstatSync } from 'fs';
import { lstatSync } from 'fs';

import vitePreprocessor from '../src/plugins/preprocessor-vite';
import { NX_PLUGIN_OPTIONS } from '../src/utils/constants';

import { spawn } from 'child_process';
import { exec, spawn } from 'child_process';
import { request as httpRequest } from 'http';
import { request as httpsRequest } from 'https';

Expand Down Expand Up @@ -75,9 +75,13 @@ function startWebServer(webServerCommand: string) {
});

return () => {
// child.kill() does not work on linux
// process.kill will kill the whole process group on unix
process.kill(-serverProcess.pid, 'SIGKILL');
if (process.platform === 'win32') {
serverProcess.kill();
} else {
// child.kill() does not work on linux
// process.kill will kill the whole process group on unix
process.kill(-serverProcess.pid, 'SIGKILL');
}
};
}

Expand Down

0 comments on commit 20efc8f

Please sign in to comment.