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: test node-debug #470

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
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
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
Loading