From 23efc4fcab2ca3b8b47539a7fb1d904efc57eb7c Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Mon, 9 May 2022 10:44:50 +0100 Subject: feat(test): Represent uncaught errors (#14513) This commit adds better reporting of uncaught errors in top level scope of testing files. This change affects both console runner as well as LSP runner. --- .../compat/test_runner/top_level_fail_cjs.out | 20 +++++++++++++++++--- .../compat/test_runner/top_level_fail_esm.out | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) (limited to 'cli/tests/testdata/compat/test_runner') diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out index 2d1471d63..be3c1b93b 100644 --- a/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out +++ b/cli/tests/testdata/compat/test_runner/top_level_fail_cjs.out @@ -1,7 +1,9 @@ +Uncaught error from ./compat/test_runner/top_level_fail_cjs.js FAILED -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + ERRORS -error: Uncaught (in promise) AssertionError: Values are not strictly equal: +./compat/test_runner/top_level_fail_cjs.js (uncaught error) +error: (in promise) AssertionError: Values are not strictly equal: [Diff] Actual / Expected @@ -10,4 +12,16 @@ error: Uncaught (in promise) AssertionError: Values are not strictly equal: - 10 + 20 -[WILDCARD] \ No newline at end of file + Error.captureStackTrace(this, stackStartFn || stackStartFunction); + ^ + at [WILDCARD] +This error was not caught from a test and caused the test runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + + FAILURES + +./compat/test_runner/top_level_fail_cjs.js (uncaught error) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + +error: Test failed diff --git a/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out index 04baeec2b..b4b313208 100644 --- a/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out +++ b/cli/tests/testdata/compat/test_runner/top_level_fail_esm.out @@ -1,7 +1,9 @@ +Uncaught error from ./compat/test_runner/top_level_fail_esm.mjs FAILED -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + ERRORS -error: Uncaught AssertionError: Values are not strictly equal: +./compat/test_runner/top_level_fail_esm.mjs (uncaught error) +error: AssertionError: Values are not strictly equal: [Diff] Actual / Expected @@ -10,4 +12,16 @@ error: Uncaught AssertionError: Values are not strictly equal: - 10 + 20 -[WILDCARD] \ No newline at end of file + Error.captureStackTrace(this, stackStartFn || stackStartFunction); + ^ + at [WILDCARD] +This error was not caught from a test and caused the test runner to fail on the referenced module. +It most likely originated from a dangling promise, event/timeout handler or top-level code. + + FAILURES + +./compat/test_runner/top_level_fail_esm.mjs (uncaught error) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD]) + +error: Test failed -- cgit v1.2.3