MCPcopy Index your code
hub / github.com/nodejs/node / assertThrowsAsync

Function assertThrowsAsync

deps/v8/test/mjsunit/es8/async-await-basic.js:9–41  ·  view source on GitHub ↗
(run, errorType, message)

Source from the content-addressed store, hash-verified

7// Do not install `AsyncFunction` constructor on global object
8
9function assertThrowsAsync(run, errorType, message) {
10 var actual;
11 var hadValue = false;
12 var hadError = false;
13 var promise = run();
14
15 if (typeof promise !== "object" || typeof promise.then !== "function") {
16 throw new MjsUnitAssertionError(
17 "Expected " + run.toString() +
18 " to return a Promise, but it returned " + PrettyPrint(promise));
19 }
20
21 promise.then(function(value) { hadValue = true; actual = value; },
22 function(error) { hadError = true; actual = error; });
23
24 assertFalse(hadValue || hadError);
25
26 %PerformMicrotaskCheckpoint();
27
28 if (!hadError) {
29 throw new MjsUnitAssertionError(
30 "Expected " + run + "() to throw " + errorType.name +
31 ", but did not throw.");
32 }
33 if (!(actual instanceof errorType))
34 throw new MjsUnitAssertionError(
35 "Expected " + run + "() to throw " + errorType.name +
36 ", but threw '" + actual + "'");
37 if (message !== void 0 && actual.message !== message)
38 throw new MjsUnitAssertionError(
39 "Expected " + run + "() to throw '" + message + "', but threw '" +
40 actual.message + "'");
41};
42
43function assertEqualsAsync(expected, run, msg) {
44 var actual;

Callers 15

jspi.jsFile · 0.50
testErrorPositionFunction · 0.50
assertCompileErrorFunction · 0.50
growable-stacks.jsFile · 0.50

Calls 5

runFunction · 0.70
PrettyPrintFunction · 0.50
assertFalseFunction · 0.50
toStringMethod · 0.45
thenMethod · 0.45

Tested by

no test coverage detected