Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): use taskkill to kill web server process when running cypress on windows #27068

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 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 { execSync, spawn } from 'child_process';
import { request as httpRequest } from 'http';
import { request as httpsRequest } from 'https';
import type { InlineConfig } from 'vite';
Expand Down Expand Up @@ -82,7 +82,13 @@ function startWebServer(webServerCommand: string) {

return () => {
if (process.platform === 'win32') {
serverProcess.kill();
try {
execSync('taskkill /pid ' + serverProcess.pid + ' /T /F');
} catch (e) {
if (process.env.NX_VERBOSE_LOGGING === 'true') {
console.error(e);
}
}
} else {
// child.kill() does not work on linux
// process.kill will kill the whole process group on unix
Expand Down