diff options
author | MichaĆ Sabiniarz <31597105+mhvsa@users.noreply.github.com> | 2020-03-31 01:01:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 19:01:19 -0400 |
commit | 30fdf6dc83d3a9d44436528959c39d3eab14cbbb (patch) | |
tree | 8f9cd11b1ae96333158b7a4be7d3d982dfde1688 /cli/js/tests/console_test.ts | |
parent | 3892d49165f00b2ce078825c204ba8ceaa21f386 (diff) |
console: print promise details (#4524)
Diffstat (limited to 'cli/js/tests/console_test.ts')
-rw-r--r-- | cli/js/tests/console_test.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/js/tests/console_test.ts b/cli/js/tests/console_test.ts index c49c941f4..88902f84b 100644 --- a/cli/js/tests/console_test.ts +++ b/cli/js/tests/console_test.ts @@ -580,6 +580,27 @@ unitTest(function consoleTestStringifyIterable() { ); }); +unitTest(async function consoleTestStringifyPromises(): Promise<void> { + const pendingPromise = new Promise((_res, _rej) => {}); + assertEquals(stringify(pendingPromise), "Promise { <pending> }"); + + const resolvedPromise = new Promise((res, _rej) => { + res("Resolved!"); + }); + assertEquals(stringify(resolvedPromise), `Promise { "Resolved!" }`); + + let rejectedPromise; + try { + rejectedPromise = new Promise((_, rej) => { + rej(Error("Whoops")); + }); + await rejectedPromise; + } catch (err) {} + const strLines = stringify(rejectedPromise).split("\n"); + assertEquals(strLines[0], "Promise {"); + assertEquals(strLines[1], " <rejected> Error: Whoops"); +}); + unitTest(function consoleTestWithCustomInspector(): void { class A { [customInspect](): string { |