mirror of
https://github.com/denoland/deno
synced 2024-08-26 19:39:52 +00:00
fix(node): node:test reports correct location (#20025)
Also removed some noisy output that caused test flakiness.
This commit is contained in:
parent
1cb16683bc
commit
d9c85e016f
|
@ -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);
|
||||
|
|
34
cli/tests/testdata/node/test.out
vendored
34
cli/tests/testdata/node/test.out
vendored
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue