Challenge - 5 Problems
Deno Test Steps Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediateWhat is the output of this Deno test with organized steps?
Consider this Deno test code that uses steps to organize output. What will be printed when running the test?
Deno
import { assertEquals } from "https://deno.land/std@0.203.0/testing/asserts.ts"; deno.test("Organized steps test", async (t) => { await t.step("Step 1", () => { console.log("Inside Step 1"); assertEquals(1 + 1, 2); }); await t.step("Step 2", () => { console.log("Inside Step 2"); assertEquals(2 * 2, 4); }); console.log("After steps"); });
Attempts:
2 left
💡 Hint
Think about the order of await calls inside the test function.
✗ Incorrect
The test runs Step 1 first, then Step 2, both awaited, so their console logs appear in order before the final console.log after steps.
❓ state_output
intermediateWhat is the final value of count after these Deno test steps?
Given this Deno test with steps modifying a shared variable, what is the final value of count after the test completes?
Deno
let count = 0; deno.test("Count increment steps", async (t) => { await t.step("Increment by 1", () => { count += 1; }); await t.step("Increment by 2", () => { count += 2; }); });
Attempts:
2 left
💡 Hint
Remember that both steps run sequentially and modify the same variable.
✗ Incorrect
The first step adds 1, the second adds 2, so total count is 3 after both steps.
📝 Syntax
advancedWhich option causes a syntax error in Deno test steps?
Identify which code snippet will cause a syntax error when defining Deno test steps.
Attempts:
2 left
💡 Hint
Look carefully at the syntax of the function parameters.
✗ Incorrect
Option D is missing a comma between the step name and the function, causing a syntax error.
🔧 Debug
advancedWhy does this Deno test step not run as expected?
This Deno test step does not print "Step executed". What is the cause?
Deno
deno.test("Missing await", (t) => { t.step("Inner step", () => { console.log("Step executed"); }); console.log("Test done"); });
Attempts:
2 left
💡 Hint
Check if the inner step is awaited or not.
✗ Incorrect
Without await, the inner step runs asynchronously and may not execute before the test finishes.
🧠 Conceptual
expertHow does Deno test steps improve test output organization?
Select the best explanation of how using test steps in Deno helps organize test output.
Attempts:
2 left
💡 Hint
Think about how nested steps affect output readability.
✗ Incorrect
Test steps create nested groups in output, making it easier to see which parts passed or failed.
