Skip to content

Commit

Permalink
fix: test node-debug (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
belom88 authored Aug 23, 2024
1 parent ca0266a commit 066f104
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/dev-tools/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 12 additions & 2 deletions modules/dev-tools/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 066f104

Please sign in to comment.