mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
fix(node): support nested tests in "node:test" (#21717)
Closes https://github.com/denoland/deno/issues/21679
This commit is contained in:
parent
576b20aa00
commit
1dd1aba244
3 changed files with 24 additions and 9 deletions
7
cli/tests/testdata/node/test.js
vendored
7
cli/tests/testdata/node/test.js
vendored
|
@ -54,6 +54,13 @@ test("async throw fail", async () => {
|
||||||
throw new Error("thrown from async throw fail");
|
throw new Error("thrown from async throw fail");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("nested test", async (t) => {
|
||||||
|
await t.test("nested 1", async (t) => {
|
||||||
|
await t.test("nested 2", () => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("async skip fail", async (t) => {
|
test("async skip fail", async (t) => {
|
||||||
t.skip();
|
t.skip();
|
||||||
throw new Error("thrown from async throw fail");
|
throw new Error("thrown from async throw fail");
|
||||||
|
|
21
cli/tests/testdata/node/test.out
vendored
21
cli/tests/testdata/node/test.out
vendored
|
@ -1,5 +1,5 @@
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
running 62 tests from ./node/test.js
|
running 63 tests from ./node/test.js
|
||||||
sync pass todo ...
|
sync pass todo ...
|
||||||
------- output -------
|
------- output -------
|
||||||
Warning: Not implemented: test.TestContext.todo
|
Warning: Not implemented: test.TestContext.todo
|
||||||
|
@ -43,6 +43,11 @@ Warning: Not implemented: test.TestContext.skip
|
||||||
async skip pass ... ok [WILDCARD]
|
async skip pass ... ok [WILDCARD]
|
||||||
async pass ... ok [WILDCARD]
|
async pass ... ok [WILDCARD]
|
||||||
async throw fail ... FAILED [WILDCARD]
|
async throw fail ... FAILED [WILDCARD]
|
||||||
|
nested test ...
|
||||||
|
nested 1 ...
|
||||||
|
nested 2 ... ok [WILDCARD]
|
||||||
|
nested 1 ... ok [WILDCARD]
|
||||||
|
nested test ... ok [WILDCARD]
|
||||||
async skip fail ...
|
async skip fail ...
|
||||||
------- output -------
|
------- output -------
|
||||||
Warning: Not implemented: test.TestContext.skip
|
Warning: Not implemented: test.TestContext.skip
|
||||||
|
@ -123,12 +128,12 @@ error: Error: thrown from async throw fail
|
||||||
throw new Error("thrown from async throw fail");
|
throw new Error("thrown from async throw fail");
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
|
|
||||||
async skip fail => ./node/test.js:57:1
|
async skip fail => ./node/test.js:64:1
|
||||||
error: Error: thrown from async throw fail
|
error: Error: thrown from async throw fail
|
||||||
throw new Error("thrown from async throw fail");
|
throw new Error("thrown from async throw fail");
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
|
|
||||||
async assertion fail => ./node/test.js:62:1
|
async assertion fail => ./node/test.js:69:1
|
||||||
error: AssertionError: Values are not strictly equal:
|
error: AssertionError: Values are not strictly equal:
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,7 +145,7 @@ error: AssertionError: Values are not strictly equal:
|
||||||
|
|
||||||
at [WILDCARD]
|
at [WILDCARD]
|
||||||
|
|
||||||
reject fail => ./node/test.js:71:1
|
reject fail => ./node/test.js:78:1
|
||||||
error: Error: rejected from reject fail
|
error: Error: rejected from reject fail
|
||||||
return Promise.reject(new Error("rejected from reject fail"));
|
return Promise.reject(new Error("rejected from reject fail"));
|
||||||
^
|
^
|
||||||
|
@ -160,11 +165,11 @@ sync fail todo => ./node/test.js:20:1
|
||||||
sync fail todo with message => ./node/test.js:25:1
|
sync fail todo with message => ./node/test.js:25:1
|
||||||
sync throw fail => ./node/test.js:42:1
|
sync throw fail => ./node/test.js:42:1
|
||||||
async throw fail => ./node/test.js:53:1
|
async throw fail => ./node/test.js:53:1
|
||||||
async skip fail => ./node/test.js:57:1
|
async skip fail => ./node/test.js:64:1
|
||||||
async assertion fail => ./node/test.js:62:1
|
async assertion fail => ./node/test.js:69:1
|
||||||
reject fail => ./node/test.js:71:1
|
reject fail => ./node/test.js:78:1
|
||||||
./node/test.js (uncaught error)
|
./node/test.js (uncaught error)
|
||||||
|
|
||||||
FAILED | 8 passed | 51 failed | 4 ignored [WILDCARD]
|
FAILED | 9 passed (2 steps) | 51 failed | 4 ignored [WILDCARD]
|
||||||
|
|
||||||
error: Test failed
|
error: Test failed
|
||||||
|
|
|
@ -56,7 +56,10 @@ class NodeTestContext {
|
||||||
const prepared = prepareOptions(name, options, fn, {});
|
const prepared = prepareOptions(name, options, fn, {});
|
||||||
return this.#denoContext.step({
|
return this.#denoContext.step({
|
||||||
name: prepared.name,
|
name: prepared.name,
|
||||||
fn: prepared.fn,
|
fn: async (denoTestContext) => {
|
||||||
|
const newNodeTextContext = new NodeTestContext(denoTestContext);
|
||||||
|
await prepared.fn(newNodeTextContext);
|
||||||
|
},
|
||||||
ignore: prepared.options.todo || prepared.options.skip,
|
ignore: prepared.options.todo || prepared.options.skip,
|
||||||
}).then(() => undefined);
|
}).then(() => undefined);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue