summaryrefslogtreecommitdiff
path: root/cli/tests/testdata
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-04-15 14:24:41 +0200
committerGitHub <noreply@github.com>2022-04-15 14:24:41 +0200
commit244926e83c7d3cae3c3ae3fc14e996e3066da43e (patch)
tree9390a5d059aa08ff003439665579bef3af626fb3 /cli/tests/testdata
parent0e4574b2e3acb6594142021f2b3e30ad532f15ef (diff)
feat(test): format user code output (#14271)
This commit changes "deno test" to better denote user output coming from test cases. This is done by printing "---- output ----" and "---- output end ----" markers if an output is produced. The output from "console" and "Deno.core.print" is captured, as well as direct writes to "Deno.stdout" and "Deno.stderr". To achieve that new APIs were added to "deno_core" crate, that allow to replace an existing resource with a different one (while keeping resource ids intact). Resources for stdout and stderr are replaced by pipes. Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tests/testdata')
-rw-r--r--cli/tests/testdata/test/steps/output_within.out31
-rw-r--r--cli/tests/testdata/test/steps/output_within.ts15
2 files changed, 46 insertions, 0 deletions
diff --git a/cli/tests/testdata/test/steps/output_within.out b/cli/tests/testdata/test/steps/output_within.out
new file mode 100644
index 000000000..b8610d903
--- /dev/null
+++ b/cli/tests/testdata/test/steps/output_within.out
@@ -0,0 +1,31 @@
+[WILDCARD]
+running 1 test from test/steps/output_within.ts
+description ...
+------- output -------
+1
+----- output end -----
+ step 1 ...
+------- output -------
+2
+----- output end -----
+ inner 1 ...
+------- output -------
+3
+----- output end -----
+ ok ([WILDCARD]ms)
+ inner 2 ...
+------- output -------
+4
+----- output end -----
+ ok ([WILDCARD]ms)
+
+------- output -------
+5
+----- output end -----
+ ok ([WILDCARD]ms)
+
+------- output -------
+6
+----- output end -----
+ok ([WILDCARD]ms)
+[WILDCARD]
diff --git a/cli/tests/testdata/test/steps/output_within.ts b/cli/tests/testdata/test/steps/output_within.ts
new file mode 100644
index 000000000..d3438a8ad
--- /dev/null
+++ b/cli/tests/testdata/test/steps/output_within.ts
@@ -0,0 +1,15 @@
+Deno.test("description", async (t) => {
+ // the output is not great, but this is an extreme scenario
+ console.log(1);
+ await t.step("step 1", async (t) => {
+ console.log(2);
+ await t.step("inner 1", () => {
+ console.log(3);
+ });
+ await t.step("inner 2", () => {
+ console.log(4);
+ });
+ console.log(5);
+ });
+ console.log(6);
+});