diff --git a/modules/dev-tools/scripts/test.sh b/modules/dev-tools/scripts/test.sh index 1b5b8dea..fa4e93a2 100755 --- a/modules/dev-tools/scripts/test.sh +++ b/modules/dev-tools/scripts/test.sh @@ -57,7 +57,7 @@ case $MODE in "node-debug") echo "Open chrome://inspect/#devices to attach debugger." - (set -x; node --inspect-brk $TEST_SCRIPT node) + (set -x; node $TEST_SCRIPT node-debug) ;; "dist") diff --git a/modules/dev-tools/src/test.ts b/modules/dev-tools/src/test.ts index eafc2535..d518faa3 100644 --- a/modules/dev-tools/src/test.ts +++ b/modules/dev-tools/src/test.ts @@ -43,6 +43,10 @@ switch (mode) { } break; + case 'node-debug': + runNodeTest(resolveNodeEntry('test'), '', {breakAndInspect: true}); + break; + case 'node': case 'dist': runNodeTest(resolveNodeEntry('test')); // Run the tests @@ -100,16 +104,22 @@ function resolveBrowserEntry(key: string): string { throw new Error(`Cannot find entry point ${key}-browser in ocular config.`); } -function runNodeTest(entry: string, command: string = '') { +function runNodeTest( + entry: string, + command: string = '', + {breakAndInspect}: {breakAndInspect: boolean} = {breakAndInspect: false} +) { // Save module alias fs.writeFileSync( resolve(ocularConfig.ocularPath, '.alias.json'), JSON.stringify(ocularConfig.aliases) ); + const inspectBrk = breakAndInspect ? '--inspect-brk' : ''; + if (ocularConfig.esm) { execShellCommand( - `${command} node --import "${ocularConfig.ocularPath}/dist/helpers/esm-register.js" --es-module-specifier-resolution=node "${entry}"` + `${command} node ${inspectBrk} --import "${ocularConfig.ocularPath}/dist/helpers/esm-register.js" --es-module-specifier-resolution=node "${entry}"` ); } else { execShellCommand(