Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
feat: Set breakpoint before file is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Oct 15, 2016
1 parent 085cd5a commit 1c60f91
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';
const { add } = require('./other');

const sum = add(40, 2);
module.exports = sum;
4 changes: 4 additions & 0 deletions examples/cjs/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
exports.add = function add(a, b) {
return a + b;
};
24 changes: 24 additions & 0 deletions test/cli/break.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,27 @@ test('stepping through breakpoints', (t) => {
.then(() => cli.quit())
.then(null, onFatal);
});

test('sb before loading file', (t) => {
const cli = startCLI(['examples/cjs/index.js']);

function onFatal(error) {
cli.quit();
throw error;
}

return cli.waitFor(/break/)
.then(() => cli.waitForPrompt())
.then(() => cli.command('sb("other.js", 3)'))
.then(() => {
t.match(cli.output, 'not loaded yet',
'warns that the script was not loaded yet');
})
.then(() => cli.stepCommand('cont'))
.then(() => {
t.match(cli.output, 'break in examples/cjs/other.js:3',
'found breakpoint in file that was not loaded yet');
})
.then(() => cli.quit())
.then(null, onFatal);
});

0 comments on commit 1c60f91

Please sign in to comment.