Skip to main content

step

method Deno.TestContext.step
Jump to headingTestContext.step(definition: TestStepDefinition): Promise<boolean>

Run a sub step of the parent test or step. Returns a promise that resolves to a boolean signifying if the step completed successfully.

The returned promise never rejects unless the arguments are invalid.

If the test was ignored the promise returns false.

Deno.test({
  name: "a parent test",
  async fn(t) {
    console.log("before the step");
    await t.step({
      name: "step 1",
      fn(t) {
        console.log("current step:", t.name);
      }
    });
    console.log("after the step");
  }
});

Parameters Jump to heading

Return Type Jump to heading

Promise<boolean>
Jump to headingTestContext.step(
name: string,
fn: (t: TestContext) => void | Promise<void>,
): Promise<boolean>

Run a sub step of the parent test or step. Returns a promise that resolves to a boolean signifying if the step completed successfully.

The returned promise never rejects unless the arguments are invalid.

If the test was ignored the promise returns false.

Deno.test(
  "a parent test",
  async (t) => {
    console.log("before the step");
    await t.step(
      "step 1",
      (t) => {
        console.log("current step:", t.name);
      }
    );
    console.log("after the step");
  }
);

Parameters Jump to heading

Jump to headingname: string
Jump to headingfn: (t: TestContext) => void | Promise<void>

Return Type Jump to heading

Promise<boolean>
Jump to headingTestContext.step(fn: (t: TestContext) => void | Promise<void>): Promise<boolean>

Run a sub step of the parent test or step. Returns a promise that resolves to a boolean signifying if the step completed successfully.

The returned promise never rejects unless the arguments are invalid.

If the test was ignored the promise returns false.

Deno.test(async function aParentTest(t) {
  console.log("before the step");
  await t.step(function step1(t) {
    console.log("current step:", t.name);
  });
  console.log("after the step");
});

Parameters Jump to heading

Jump to headingfn: (t: TestContext) => void | Promise<void>

Return Type Jump to heading

Promise<boolean>
Back to top