Skip to content

Commit 700a062

Browse files
pete3249Trott
authored andcommitted
test: change promises to async/await in test-debugger-exceptions
1 parent 7e0097d commit 700a062

File tree

1 file changed

+31
-38
lines changed

1 file changed

+31
-38
lines changed

test/sequential/test-debugger-exceptions.js

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,52 +20,45 @@ const path = require('path');
2020
throw error;
2121
}
2222

23-
cli.waitForInitialBreak()
24-
.then(() => cli.waitForPrompt())
25-
.then(() => {
23+
(async () => {
24+
try {
25+
await cli.waitForInitialBreak();
26+
await cli.waitForPrompt();
27+
await cli.waitForPrompt();
2628
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/))
3129

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

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(() => {
44+
// Next run: With `breakOnUncaught` it only pauses on the 2nd exception.
45+
await cli.command('breakOnUncaught');
46+
await cli.stepCommand('r'); // Also, the setting survives the restart.
47+
await cli.waitForInitialBreak();
48+
await cli.waitForInitialBreak();
5349
assert.deepStrictEqual(cli.breakInfo, { filename: script, line: 1 });
54-
})
55-
.then(() => cli.stepCommand('c'))
56-
.then(() => {
50+
await cli.stepCommand('c');
5751
assert.ok(cli.output.includes(`exception in ${script}:9`));
58-
})
5952

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(() => {
53+
// Next run: Back to the initial state! It should die again.
54+
await cli.command('breakOnNone');
55+
await cli.stepCommand('r');
6556
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);
57+
await cli.command('c');
58+
await cli.waitFor(/disconnect/);
59+
await cli.quit();
60+
} finally {
61+
onFatal();
62+
}
63+
})().then(common.mustCall());
7164
}

0 commit comments

Comments
 (0)