summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-08-02 17:11:04 +0200
committerGitHub <noreply@github.com>2023-08-02 17:11:04 +0200
commitd9c85e016f054fd3b6c68a54213e7c0ad8c3a8f4 (patch)
treeedc896aceafb0c35ddedea2ba28cc7ce600bf6e7
parent1cb16683bcaf3223de560a7560647aadfea78d31 (diff)
fix(node): node:test reports correct location (#20025)
Also removed some noisy output that caused test flakiness.
-rw-r--r--cli/js/40_testing.js20
-rw-r--r--cli/tests/testdata/node/test.out34
-rw-r--r--ext/node/polyfills/testing.ts13
3 files changed, 31 insertions, 36 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js
index 8b1557fbf..d119552e4 100644
--- a/cli/js/40_testing.js
+++ b/cli/js/40_testing.js
@@ -677,11 +677,21 @@ function test(
// Delete this prop in case the user passed it. It's used to detect steps.
delete testDesc.parent;
const jsError = core.destructureError(new Error());
- testDesc.location = {
- fileName: jsError.frames[1].fileName,
- lineNumber: jsError.frames[1].lineNumber,
- columnNumber: jsError.frames[1].columnNumber,
- };
+ let location;
+
+ for (let i = 0; i < jsError.frames.length; i++) {
+ const filename = jsError.frames[i].fileName;
+ if (filename.startsWith("ext:") || filename.startsWith("node:")) {
+ continue;
+ }
+ location = {
+ fileName: jsError.frames[i].fileName,
+ lineNumber: jsError.frames[i].lineNumber,
+ columnNumber: jsError.frames[i].columnNumber,
+ };
+ break;
+ }
+ testDesc.location = location;
testDesc.fn = wrapTest(testDesc);
const { id, origin } = ops.op_register_test(testDesc);
diff --git a/cli/tests/testdata/node/test.out b/cli/tests/testdata/node/test.out
index afda0eca3..8b7f0780f 100644
--- a/cli/tests/testdata/node/test.out
+++ b/cli/tests/testdata/node/test.out
@@ -1,10 +1,4 @@
[WILDCARD]
-Warning: Not implemented: test.options.concurrency
-Warning: Not implemented: test.options.concurrency
-Warning: Not implemented: test.options.timeout
-Warning: Not implemented: test.options.timeout
-Warning: Not implemented: test.options.timeout
-Warning: Not implemented: test.options.timeout
running 62 tests from ./node/test.js
sync pass todo ...
------- output -------
@@ -109,32 +103,32 @@ unfinished test with unhandledRejection ... cancelled ([WILDCARD])
ERRORS
-sync fail todo => node:test:135:10
+sync fail todo => ./node/test.js:20:1
error: Error: thrown from sync fail todo
throw new Error("thrown from sync fail todo");
[WILDCARD]
-sync fail todo with message => node:test:135:10
+sync fail todo with message => ./node/test.js:25:1
error: Error: thrown from sync fail todo with message
throw new Error("thrown from sync fail todo with message");
[WILDCARD]
-sync throw fail => node:test:135:10
+sync throw fail => ./node/test.js:42:1
error: Error: thrown from sync throw fail
throw new Error("thrown from sync throw fail");
[WILDCARD]
-async throw fail => node:test:135:10
+async throw fail => ./node/test.js:53:1
error: Error: thrown from async throw fail
throw new Error("thrown from async throw fail");
[WILDCARD]
-async skip fail => node:test:135:10
+async skip fail => ./node/test.js:57:1
error: Error: thrown from async throw fail
throw new Error("thrown from async throw fail");
[WILDCARD]
-async assertion fail => node:test:135:10
+async assertion fail => ./node/test.js:62:1
error: AssertionError: Values are not strictly equal:
@@ -146,7 +140,7 @@ error: AssertionError: Values are not strictly equal:
at [WILDCARD]
-reject fail => node:test:135:10
+reject fail => ./node/test.js:71:1
error: Error: rejected from reject fail
return Promise.reject(new Error("rejected from reject fail"));
^
@@ -162,13 +156,13 @@ It most likely originated from a dangling promise, event/timeout handler or top-
FAILURES
-sync fail todo => node:test:135:10
-sync fail todo with message => node:test:135:10
-sync throw fail => node:test:135:10
-async throw fail => node:test:135:10
-async skip fail => node:test:135:10
-async assertion fail => node:test:135:10
-reject fail => node:test:135:10
+sync fail todo => ./node/test.js:20:1
+sync fail todo with message => ./node/test.js:25:1
+sync throw fail => ./node/test.js:42:1
+async throw fail => ./node/test.js:53:1
+async skip fail => ./node/test.js:57:1
+async assertion fail => ./node/test.js:62:1
+reject fail => ./node/test.js:71:1
./node/test.js (uncaught error)
FAILED | 8 passed | 51 failed | 4 ignored [WILDCARD]
diff --git a/ext/node/polyfills/testing.ts b/ext/node/polyfills/testing.ts
index 2c112d9fb..192a0cc71 100644
--- a/ext/node/polyfills/testing.ts
+++ b/ext/node/polyfills/testing.ts
@@ -110,17 +110,8 @@ function prepareOptions(name, options, fn, overrides) {
}
const finalOptions = { ...options, ...overrides };
- const { concurrency, timeout, signal } = finalOptions;
-
- if (typeof concurrency !== "undefined") {
- warnNotImplemented("test.options.concurrency");
- }
- if (typeof timeout !== "undefined") {
- warnNotImplemented("test.options.timeout");
- }
- if (typeof signal !== "undefined") {
- warnNotImplemented("test.options.signal");
- }
+ // TODO(bartlomieju): these options are currently not handled
+ // const { concurrency, timeout, signal } = finalOptions;
if (typeof fn !== "function") {
fn = noop;