Skip to content

Commit ee3c6a4

Browse files
pete3249danielleadams
authored andcommitted
test: use async/await in test-debugger-exceptions
PR-URL: #44690 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 9f14625 commit ee3c6a4

File tree

1 file changed

+30
-43
lines changed

1 file changed

+30
-43
lines changed

test/sequential/test-debugger-exceptions.js

+30-43
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,44 @@ const path = require('path');
1515
const script = path.relative(process.cwd(), scriptFullPath);
1616
const cli = startCLI([script]);
1717

18-
function onFatal(error) {
19-
cli.quit();
20-
throw error;
21-
}
22-
23-
cli.waitForInitialBreak()
24-
.then(() => cli.waitForPrompt())
25-
.then(() => {
18+
(async () => {
19+
try {
20+
await cli.waitForInitialBreak();
21+
await cli.waitForPrompt();
22+
await cli.waitForPrompt();
2623
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
27-
})
28-
// Making sure it will die by default:
29-
.then(() => cli.command('c'))
30-
.then(() => cli.waitFor(/disconnect/))
3124

32-
// Next run: With `breakOnException` it pauses in both places.
33-
.then(() => cli.stepCommand('r'))
34-
.then(() => cli.waitForInitialBreak())
35-
.then(() => {
25+
// Making sure it will die by default:
26+
await cli.command('c');
27+
await cli.waitFor(/disconnect/);
28+
29+
// Next run: With `breakOnException` it pauses in both places.
30+
await cli.stepCommand('r');
31+
await cli.waitForInitialBreak();
3632
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
37-
})
38-
.then(() => cli.command('breakOnException'))
39-
.then(() => cli.stepCommand('c'))
40-
.then(() => {
33+
await cli.command('breakOnException');
34+
await cli.stepCommand('c');
4135
assert.ok(cli.output.includes(`exception in ${script}:3`));
42-
})
43-
.then(() => cli.stepCommand('c'))
44-
.then(() => {
36+
await cli.stepCommand('c');
4537
assert.ok(cli.output.includes(`exception in ${script}:9`));
46-
})
4738

48-
// Next run: With `breakOnUncaught` it only pauses on the 2nd exception.
49-
.then(() => cli.command('breakOnUncaught'))
50-
.then(() => cli.stepCommand('r')) // Also, the setting survives the restart.
51-
.then(() => cli.waitForInitialBreak())
52-
.then(() => {
39+
// Next run: With `breakOnUncaught` it only pauses on the 2nd exception.
40+
await cli.command('breakOnUncaught');
41+
await cli.stepCommand('r'); // Also, the setting survives the restart.
42+
await cli.waitForInitialBreak();
5343
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
54-
})
55-
.then(() => cli.stepCommand('c'))
56-
.then(() => {
44+
await cli.stepCommand('c');
5745
assert.ok(cli.output.includes(`exception in ${script}:9`));
58-
})
5946

60-
// Next run: Back to the initial state! It should die again.
61-
.then(() => cli.command('breakOnNone'))
62-
.then(() => cli.stepCommand('r'))
63-
.then(() => cli.waitForInitialBreak())
64-
.then(() => {
47+
// Next run: Back to the initial state! It should die again.
48+
await cli.command('breakOnNone');
49+
await cli.stepCommand('r');
50+
await cli.waitForInitialBreak();
6551
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
66-
})
67-
.then(() => cli.command('c'))
68-
.then(() => cli.waitFor(/disconnect/))
69-
.then(() => cli.quit())
70-
.then(null, onFatal);
52+
await cli.command('c');
53+
await cli.waitFor(/disconnect/);
54+
} finally {
55+
cli.quit();
56+
}
57+
})().then(common.mustCall());
7158
}

0 commit comments

Comments
 (0)