summaryrefslogtreecommitdiff
path: root/tests/specs/test/steps_tap_failing_steps
diff options
context:
space:
mode:
authorHasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com>2024-09-16 22:38:40 +0300
committerGitHub <noreply@github.com>2024-09-16 19:38:40 +0000
commite0b9c745c15720914f14996bf357d5b375e2dbd8 (patch)
tree0dfc717082bedb2eec13eceb5cdeb1ef12b8f7f5 /tests/specs/test/steps_tap_failing_steps
parent6ce16145dd12d8a272cb543871276c33c8201a37 (diff)
chore: deprecate test itests (#25512)
This PR is part of #22907 --------- Signed-off-by: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'tests/specs/test/steps_tap_failing_steps')
-rw-r--r--tests/specs/test/steps_tap_failing_steps/__test__.jsonc8
-rw-r--r--tests/specs/test/steps_tap_failing_steps/failing_steps.tap.out43
-rw-r--r--tests/specs/test/steps_tap_failing_steps/failing_steps.ts27
3 files changed, 78 insertions, 0 deletions
diff --git a/tests/specs/test/steps_tap_failing_steps/__test__.jsonc b/tests/specs/test/steps_tap_failing_steps/__test__.jsonc
new file mode 100644
index 000000000..fc83a7cdf
--- /dev/null
+++ b/tests/specs/test/steps_tap_failing_steps/__test__.jsonc
@@ -0,0 +1,8 @@
+{
+ "args": "test --reporter=tap failing_steps.ts",
+ "exitCode": 1,
+ "envs": {
+ "NO_COLOR": "1"
+ },
+ "output": "failing_steps.tap.out"
+}
diff --git a/tests/specs/test/steps_tap_failing_steps/failing_steps.tap.out b/tests/specs/test/steps_tap_failing_steps/failing_steps.tap.out
new file mode 100644
index 000000000..b47b9fed3
--- /dev/null
+++ b/tests/specs/test/steps_tap_failing_steps/failing_steps.tap.out
@@ -0,0 +1,43 @@
+TAP version 14
+# [WILDCARD]failing_steps.ts
+# Subtest: nested failure
+ not ok 1 - inner 1
+ ---
+ {"message":"Error: Failed.\n throw new Error(\"Failed.\");\n ^\n at [WILDCARD]/failing_steps.ts:[WILDCARD]\n[WILDCARD]","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+ ok 2 - inner 2
+ not ok 3 - step 1
+ ---
+ {"message":"1 test step failed.","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+ 1..3
+not ok 1 - nested failure
+ ---
+ {"message":"1 test step failed.","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+# Subtest: multiple test step failures
+ not ok 1 - step 1
+ ---
+ {"message":"Error: Fail.\n throw new Error(\"Fail.\");\n ^\n at [WILDCARD]/failing_steps.ts:[WILDCARD]\n[WILDCARD]","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+ not ok 2 - step 2
+ ---
+ {"message":"Error: Fail.\n await t.step(\"step 2\", () => Promise.reject(new Error(\"Fail.\")));\n ^\n at [WILDCARD]/failing_steps.ts:[WILDCARD]\n[WILDCARD]","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+ 1..2
+not ok 2 - multiple test step failures
+ ---
+ {"message":"2 test steps failed.","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+# Subtest: failing step in failing test
+ not ok 1 - step 1
+ ---
+ {"message":"Error: Fail.\n throw new Error(\"Fail.\");\n ^\n at [WILDCARD]/failing_steps.ts:[WILDCARD]\n[WILDCARD]","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+ 1..1
+not ok 3 - failing step in failing test
+ ---
+ {"message":"Error: Fail test.\n throw new Error(\"Fail test.\");\n ^\n at [WILDCARD]/failing_steps.ts:[WILDCARD]","severity":"fail","at":{"file":"[WILDCARD]failing_steps.ts","line":[WILDCARD]}}
+ ...
+1..3
+error: Test failed
diff --git a/tests/specs/test/steps_tap_failing_steps/failing_steps.ts b/tests/specs/test/steps_tap_failing_steps/failing_steps.ts
new file mode 100644
index 000000000..efa18d54e
--- /dev/null
+++ b/tests/specs/test/steps_tap_failing_steps/failing_steps.ts
@@ -0,0 +1,27 @@
+Deno.test("nested failure", async (t) => {
+ const success = await t.step("step 1", async (t) => {
+ let success = await t.step("inner 1", () => {
+ throw new Error("Failed.");
+ });
+ if (success) throw new Error("Expected failure");
+
+ success = await t.step("inner 2", () => {});
+ if (!success) throw new Error("Expected success");
+ });
+
+ if (success) throw new Error("Expected failure");
+});
+
+Deno.test("multiple test step failures", async (t) => {
+ await t.step("step 1", () => {
+ throw new Error("Fail.");
+ });
+ await t.step("step 2", () => Promise.reject(new Error("Fail.")));
+});
+
+Deno.test("failing step in failing test", async (t) => {
+ await t.step("step 1", () => {
+ throw new Error("Fail.");
+ });
+ throw new Error("Fail test.");
+});