diff --git a/package-lock.json b/package-lock.json index 4b555858fa..43baafa456 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,7 @@ "rollup-plugin-rename-node-modules": "^1.3.1", "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-string": "^3.0.0", + "tree-kill": "^1.2.2", "ts-jest": "^26.0.0", "ts-node": "^9.0.0", "tsconfig-paths": "^3.10.1", @@ -24600,6 +24601,15 @@ "node": ">=8" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/trim-newlines": { "version": "3.0.1", "dev": true, @@ -43561,6 +43571,12 @@ "punycode": "^2.1.1" } }, + "tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true + }, "trim-newlines": { "version": "3.0.1", "dev": true diff --git a/package.json b/package.json index c5649e0fe2..f547f2a60d 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "rollup-plugin-rename-node-modules": "^1.3.1", "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-string": "^3.0.0", + "tree-kill": "^1.2.2", "ts-jest": "^26.0.0", "ts-node": "^9.0.0", "tsconfig-paths": "^3.10.1", diff --git a/test/jest-global-setup.ts b/test/jest-global-setup.ts index 33488066fa..82954fa7c4 100644 --- a/test/jest-global-setup.ts +++ b/test/jest-global-setup.ts @@ -6,7 +6,14 @@ module.exports = async function () { if (!process.env.GITHUB_ACTIONS) { - const httpServerProcess = spawn('http-server', ['-c-1', `${join(process.cwd(), './packages')}`]); + const httpServerProcess = spawn( + 'http-server', + ['-c-1', `${join(process.cwd(), './packages')}`], + { + // See https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows + shell: process.platform === 'win32', + }, + ); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore diff --git a/test/jest-global-teardown.ts b/test/jest-global-teardown.ts index 2490f4691a..91b132a48d 100644 --- a/test/jest-global-teardown.ts +++ b/test/jest-global-teardown.ts @@ -1,4 +1,5 @@ import type { ChildProcess } from 'child_process'; +import kill from 'tree-kill'; // eslint-disable-next-line func-names module.exports = async function () @@ -14,7 +15,7 @@ module.exports = async function () httpServerProcess.on('close', resolve); }); - httpServerProcess.kill(); + kill(httpServerProcess.pid); await processClose; } };