Skip to content

Commit 2dada89

Browse files
committed
fixed debug for jest, jasmine and mocha
1 parent 09f5884 commit 2dada89

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

@bellatrix/runner/bellatrix.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ switch (config.frameworkSettings.testSettings.testFramework) {
237237
const tsPathsEsmLoaderPath = new URL(import.meta.resolve('ts-paths-esm-loader')).pathname;
238238
const cliPath = findFilePath([ 'node_modules/jasmine/bin/jasmine.js' ]);
239239
const jasmineConfigPath = new URL(import.meta.resolve('./jasmine/config.json')).pathname;
240-
const cliArgs = [ cliPath, `--config=${jasmineConfigPath}` ];
240+
const cliArgs = [ `--config=${jasmineConfigPath}` ];
241241

242242
switch (reporter) {
243243
case 'json': throw new Error('Jasmine does not have default JSON reporter');
@@ -265,20 +265,26 @@ switch (config.frameworkSettings.testSettings.testFramework) {
265265
case 'xunit': throw new Error('Jasmine does not have xUnit reporter');
266266
}
267267

268-
spawnSync('node', cliArgs, {
268+
const child = fork(cliPath, cliArgs, {
269269
stdio: 'inherit',
270270
env: {
271271
...process.env,
272272
NODE_OPTIONS: `--loader=${tsPathsEsmLoaderPath} --experimental-specifier-resolution=node --no-warnings`,
273273
},
274+
execArgv: ['--inspect=12016'],
275+
});
276+
277+
// Handle child process events (optional)
278+
child.on('exit', (code) => {
279+
console.log(`Child process exited with code ${code}`);
274280
});
275281

276282
break;
277283
}
278284
case 'mocha': {
279285
const tsPathsEsmLoaderPath = new URL(import.meta.resolve('ts-paths-esm-loader')).pathname;
280286
const cliPath = findFilePath([ 'node_modules/mocha/bin/mocha.js' ]);
281-
const cliArgs = [ cliPath, '**/*.test.?(m){ts,js}' ];
287+
const cliArgs = [ '**/*.test.?(m){ts,js}' ];
282288

283289
switch (reporter) {
284290
case 'json': {
@@ -307,12 +313,18 @@ switch (config.frameworkSettings.testSettings.testFramework) {
307313
}
308314
}
309315

310-
spawnSync('node', cliArgs, {
316+
const child = fork(cliPath, cliArgs, {
311317
stdio: 'inherit',
312318
env: {
313319
...process.env,
314320
NODE_OPTIONS: `--loader=${tsPathsEsmLoaderPath} --experimental-specifier-resolution=node --no-warnings`,
315-
}
321+
},
322+
execArgv: ['--inspect=12016'],
323+
});
324+
325+
// Handle child process events (optional)
326+
child.on('exit', (code) => {
327+
console.log(`Child process exited with code ${code}`);
316328
});
317329

318330
break;
@@ -322,7 +334,7 @@ switch (config.frameworkSettings.testSettings.testFramework) {
322334
const tsPathsEsmLoaderPath = new URL(import.meta.resolve('ts-paths-esm-loader')).pathname;
323335
const cliPath = join(new URL(import.meta.resolve('jest-cli')).pathname, '..', '..', 'bin', 'jest.js');
324336
const testMatch = '\\.test\\.(ts|js)';
325-
const cliArgs = [ cliPath ];
337+
const cliArgs = [];
326338

327339
switch (reporter) {
328340
case 'json': throw new Error('Jest does not have default JSON reporter');
@@ -367,12 +379,18 @@ switch (config.frameworkSettings.testSettings.testFramework) {
367379
}
368380
}
369381

370-
spawnSync('node', cliArgs, {
382+
const child = fork(cliPath, cliArgs, {
371383
stdio: 'inherit',
372384
env: {
373385
...process.env,
374386
NODE_OPTIONS: `--loader=${tsPathsEsmLoaderPath} --experimental-vm-modules --no-warnings`,
375-
}
387+
},
388+
execArgv: ['--inspect=12016'],
389+
});
390+
391+
// Handle child process events (optional)
392+
child.on('exit', (code) => {
393+
console.log(`Child process exited with code ${code}`);
376394
});
377395

378396
break;

0 commit comments

Comments
 (0)