From e0b9c745c15720914f14996bf357d5b375e2dbd8 Mon Sep 17 00:00:00 2001 From: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:38:40 +0300 Subject: chore: deprecate test itests (#25512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR is part of #22907 --------- Signed-off-by: HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> Co-authored-by: Bartek IwaƄczuk --- .../specs/test/steps_failing_steps/__test__.jsonc | 5 ++ .../test/steps_failing_steps/failing_steps.out | 59 ++++++++++++++++++++++ .../test/steps_failing_steps/failing_steps.ts | 27 ++++++++++ 3 files changed, 91 insertions(+) create mode 100644 tests/specs/test/steps_failing_steps/__test__.jsonc create mode 100644 tests/specs/test/steps_failing_steps/failing_steps.out create mode 100644 tests/specs/test/steps_failing_steps/failing_steps.ts (limited to 'tests/specs/test/steps_failing_steps') diff --git a/tests/specs/test/steps_failing_steps/__test__.jsonc b/tests/specs/test/steps_failing_steps/__test__.jsonc new file mode 100644 index 000000000..f4194c50c --- /dev/null +++ b/tests/specs/test/steps_failing_steps/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "test failing_steps.ts", + "exitCode": 1, + "output": "failing_steps.out" +} diff --git a/tests/specs/test/steps_failing_steps/failing_steps.out b/tests/specs/test/steps_failing_steps/failing_steps.out new file mode 100644 index 000000000..f66e089bc --- /dev/null +++ b/tests/specs/test/steps_failing_steps/failing_steps.out @@ -0,0 +1,59 @@ +[WILDCARD] +running 3 tests from [WILDCARD]failing_steps.ts +nested failure ... + step 1 ... + inner 1 ... FAILED ([WILDCARD]) + inner 2 ... ok ([WILDCARD]) + step 1 ... FAILED (due to 1 failed step) ([WILDCARD]) +nested failure ... FAILED (due to 1 failed step) ([WILDCARD]) +multiple test step failures ... + step 1 ... FAILED ([WILDCARD]) + step 2 ... FAILED ([WILDCARD]) +multiple test step failures ... FAILED (due to 2 failed steps) ([WILDCARD]) +failing step in failing test ... + step 1 ... FAILED ([WILDCARD]) +failing step in failing test ... FAILED ([WILDCARD]) + + ERRORS + +nested failure ... step 1 ... inner 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +error: Error: Failed. + throw new Error("Failed."); + ^ + at [WILDCARD]/failing_steps.ts:[WILDCARD] + +multiple test step failures ... step 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +error: Error: Fail. + throw new Error("Fail."); + ^ + at [WILDCARD]/failing_steps.ts:[WILDCARD] + +multiple test step failures ... step 2 => [WILDCARD]failing_steps.ts:[WILDCARD] +error: Error: Fail. + await t.step("step 2", () => Promise.reject(new Error("Fail."))); + ^ + at [WILDCARD]/failing_steps.ts:[WILDCARD] + +failing step in failing test ... step 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +error: Error: Fail. + throw new Error("Fail."); + ^ + at [WILDCARD]/failing_steps.ts:[WILDCARD] + +failing step in failing test => [WILDCARD]failing_steps.ts:[WILDCARD] +error: Error: Fail test. + throw new Error("Fail test."); + ^ + at [WILDCARD]/failing_steps.ts:[WILDCARD] + + FAILURES + +nested failure ... step 1 ... inner 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +multiple test step failures ... step 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +multiple test step failures ... step 2 => [WILDCARD]failing_steps.ts:[WILDCARD] +failing step in failing test ... step 1 => [WILDCARD]failing_steps.ts:[WILDCARD] +failing step in failing test => [WILDCARD]failing_steps.ts:[WILDCARD] + +FAILED | 0 passed (1 step) | 3 failed (5 steps) ([WILDCARD]) + +error: Test failed diff --git a/tests/specs/test/steps_failing_steps/failing_steps.ts b/tests/specs/test/steps_failing_steps/failing_steps.ts new file mode 100644 index 000000000..efa18d54e --- /dev/null +++ b/tests/specs/test/steps_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."); +}); -- cgit v1.2.3