Bird
Raised Fist0
Denoframework~20 mins

Test steps for organized output in Deno - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Deno Test Steps Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What 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");
});
AInside Step 1\nInside Step 2\nAfter steps
BAfter steps\nInside Step 1\nInside Step 2
CInside Step 1\nAfter steps\nInside Step 2
DInside Step 2\nInside Step 1\nAfter steps
Attempts:
2 left
💡 Hint
Think about the order of await calls inside the test function.
❓ state_output
intermediate
2:00remaining
What 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;
  });
});
A3
B1
C0
D2
Attempts:
2 left
💡 Hint
Remember that both steps run sequentially and modify the same variable.
📝 Syntax
advanced
2:00remaining
Which option causes a syntax error in Deno test steps?
Identify which code snippet will cause a syntax error when defining Deno test steps.
Aawait t.step("Step A", () => { console.log("A"); });
Bawait t.step("Step B", async () => { await Promise.resolve(); });
Cawait t.step("Step D", () => { console.log("D"); });
Dawait t.step("Step C" () => { console.log("C"); });
Attempts:
2 left
💡 Hint
Look carefully at the syntax of the function parameters.
🔧 Debug
advanced
2:00remaining
Why 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");
});
Aconsole.log is not allowed inside test steps.
Bt.step requires an async callback function.
CThe inner step is not awaited, so it may not run before test ends.
DThe test function must be async to use t.step.
Attempts:
2 left
💡 Hint
Check if the inner step is awaited or not.
🧠 Conceptual
expert
2:00remaining
How does Deno test steps improve test output organization?
Select the best explanation of how using test steps in Deno helps organize test output.
ATest steps run all tests in parallel to speed up execution.
BTest steps allow grouping related assertions and logs, showing nested output for clarity.
CTest steps automatically retry failed assertions to improve reliability.
DTest steps replace the need for separate test files by merging all tests.
Attempts:
2 left
💡 Hint
Think about how nested steps affect output readability.

Practice

(1/5)
1. What is the main benefit of organizing test steps clearly in deno.test?
easy
A. Automatically fixes code errors
B. Runs tests faster
C. Reduces the number of tests needed
D. Makes tests easier to read and debug

Solution

  1. Step 1: Understand the purpose of test organization

    Organizing test steps clearly helps anyone reading the test understand what each part does.
  2. Step 2: Connect organization to debugging ease

    Clear steps make it easier to find where a test fails and fix it quickly.
  3. Final Answer:

    Makes tests easier to read and debug -> Option D
  4. Quick Check:

    Clear test steps = easier debugging [OK]
Hint: Clear test steps help find bugs faster [OK]
Common Mistakes:
  • Thinking organization speeds up test execution
  • Believing fewer tests are needed with organization
  • Assuming tests fix code automatically
2. Which of the following is the correct way to define a test with a clear name in Deno?
easy
A. deno.check('Check addition', () => { /* test code */ })
B. test('Check addition', () => { /* test code */ })
C. deno.test('Check addition', () => { /* test code */ })
D. deno.runTest('Check addition', () => { /* test code */ })

Solution

  1. Step 1: Recall Deno test syntax

    Deno uses the deno.test function to define tests with a name and a function.
  2. Step 2: Identify the correct function call

    Only deno.test matches the correct syntax; others are invalid or do not exist.
  3. Final Answer:

    deno.test('Check addition', () => { /* test code */ }) -> Option C
  4. Quick Check:

    Use deno.test() to define tests [OK]
Hint: Use deno.test() with a descriptive name [OK]
Common Mistakes:
  • Using just test() without deno prefix
  • Using non-existent functions like deno.check()
  • Confusing runTest with test
3. Consider this Deno test code:
deno.test('Sum test', () => {
  const a = 2;
  const b = 3;
  const result = a + b;
  if (result !== 5) throw new Error('Sum failed');
});

What happens when you run this test?
medium
A. Test outputs the sum value
B. Test passes silently with no errors
C. Syntax error stops the test
D. Test fails with 'Sum failed' error

Solution

  1. Step 1: Analyze the sum calculation

    Variables a=2 and b=3 sum to 5, so result is 5.
  2. Step 2: Check the condition for error

    The condition result !== 5 is false, so no error is thrown.
  3. Final Answer:

    Test passes silently with no errors -> Option B
  4. Quick Check:

    Correct sum means no error thrown [OK]
Hint: Check if error condition matches actual result [OK]
Common Mistakes:
  • Assuming test outputs values automatically
  • Thinking test fails without error throw
  • Confusing syntax error with runtime error
4. This Deno test code has an error:
deno.test('Check value', () => {
  const val = 10
  if val !== 10 {
    throw new Error('Value mismatch')
  }
});

What is the error and how to fix it?
medium
A. Missing parentheses in if condition; add parentheses
B. Missing semicolon after val declaration; add semicolon
C. Wrong function name; use deno.check instead of deno.test
D. Cannot throw error inside test; remove throw statement

Solution

  1. Step 1: Identify syntax error in if statement

    The if condition lacks parentheses around val !== 10, which is required in JavaScript/TypeScript.
  2. Step 2: Fix the if statement syntax

    Add parentheses: if (val !== 10) { ... } to correct the syntax.
  3. Final Answer:

    Missing parentheses in if condition; add parentheses -> Option A
  4. Quick Check:

    If conditions need parentheses [OK]
Hint: Always wrap if conditions in parentheses [OK]
Common Mistakes:
  • Ignoring missing parentheses error
  • Thinking semicolons cause this error
  • Confusing function names in Deno tests
5. You want to organize a Deno test that checks multiple steps: fetching data, validating it, and saving results. Which approach best organizes these steps for clear output?
hard
A. Use one test with clear comments and separate code blocks for each step
B. Write all steps in one line without comments
C. Create multiple tests but with vague names like 'Test 1', 'Test 2'
D. Skip comments and rely on console.log for clarity

Solution

  1. Step 1: Understand importance of clear test structure

    Organizing steps with comments and separate code blocks helps readers follow the test flow easily.
  2. Step 2: Compare options for clarity

    One test with clear comments is better than vague test names or no comments, which confuse readers.
  3. Final Answer:

    Use one test with clear comments and separate code blocks for each step -> Option A
  4. Quick Check:

    Clear comments + code blocks = organized tests [OK]
Hint: Comment each step clearly inside one test [OK]
Common Mistakes:
  • Writing unclear test names
  • Skipping comments thinking code is self-explanatory
  • Relying only on console logs for understanding
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard