Bird
Raised Fist0
Denoframework~20 mins

Code coverage reporting in Deno - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Deno Coverage Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Understanding Deno coverage output format
What is the output of the following Deno coverage command snippet when run on a project with 3 files, where only 2 files have coverage data?
Deno
deno coverage --json
// Output example snippet:
{
  "files": {
    "file1.ts": {"lines": {"total": 10, "covered": 8}},
    "file2.ts": {"lines": {"total": 5, "covered": 5}}
  },
  "total": {"lines": {"total": 15, "covered": 13}}
}
AA JSON object showing coverage details only for file1.ts and file2.ts, with total lines 15 and covered lines 13
BA JSON object including all 3 files with zero coverage for the third file
CA plain text summary showing coverage percentages per file
DAn error message indicating missing coverage data for one file
Attempts:
2 left
💡 Hint
Deno coverage JSON output only includes files with coverage data.
❓ component_behavior
intermediate
1:30remaining
Effect of --lcov flag in Deno coverage
What happens when you run `deno coverage --lcov` on a project?
AIt runs tests and shows coverage percentages inline
BIt outputs coverage data as JSON to the console
CIt clears previous coverage data before running tests
DIt generates a coverage report in lcov format suitable for tools like Codecov
Attempts:
2 left
💡 Hint
lcov is a common coverage format used by many CI tools.
🔧 Debug
advanced
2:00remaining
Diagnosing missing coverage data in Deno
You ran `deno coverage` but the report shows zero coverage for all files. Which of the following is the most likely cause?
AYou ran coverage without running tests first to generate coverage data
BYour source files are not in the current directory
CYou used the --lcov flag instead of --json
DYou have syntax errors in your test files
Attempts:
2 left
💡 Hint
Coverage data is generated when tests run with coverage enabled.
📝 Syntax
advanced
1:30remaining
Correct command to generate coverage report for a specific directory
Which of the following commands correctly generates a coverage report for the 'src' directory using Deno?
Adeno coverage --include=src
Bdeno coverage --include=./src
Cdeno coverage --include=src/**
Ddeno coverage --include=src/
Attempts:
2 left
💡 Hint
Deno coverage uses glob patterns like src/** to include all files under a directory.
❓ lifecycle
expert
2:30remaining
Sequence of steps to generate and view coverage in Deno
What is the correct sequence of commands to generate coverage data and then view a coverage report in Deno?
A1,4,2,3
B3,1,4,2
C3,1,2,4
D1,3,4,2
Attempts:
2 left
💡 Hint
You clear old data, run tests to generate new data, save it, then view report.

Practice

(1/5)
1. What does the deno test --coverage command do?
easy
A. Installs coverage tools for Deno
B. Only runs tests without coverage data
C. Generates a coverage report without running tests
D. Runs tests and collects code coverage data

Solution

  1. Step 1: Understand the purpose of deno test --coverage

    This command runs your test files and collects data on which parts of your code were executed during testing.
  2. Step 2: Differentiate from other commands

    Unlike just running tests, this command also tracks coverage. It does not generate reports directly; that is done by deno coverage.
  3. Final Answer:

    Runs tests and collects code coverage data -> Option D
  4. Quick Check:

    deno test --coverage collects coverage data [OK]
Hint: Remember: test runs + coverage data collection together [OK]
Common Mistakes:
  • Thinking it only runs tests without coverage
  • Confusing coverage data collection with report generation
  • Assuming it installs tools instead of running tests
2. Which of the following is the correct command to view a coverage report in the terminal?
easy
A. deno coverage --reporter=text
B. deno test --view-coverage
C. deno coverage --show
D. deno test --coverage-report

Solution

  1. Step 1: Identify the command to view coverage

    The deno coverage command is used to view or export coverage reports after running tests with coverage.
  2. Step 2: Recognize the correct flag for terminal output

    The flag --reporter=text tells Deno to show the coverage report in the terminal.
  3. Final Answer:

    deno coverage --reporter=text -> Option A
  4. Quick Check:

    Use deno coverage with --reporter=text to view coverage [OK]
Hint: Use deno coverage with --reporter=text to see output [OK]
Common Mistakes:
  • Using deno test flags to view coverage report
  • Assuming --show or --view-coverage are valid flags
  • Confusing test and coverage commands
3. Given the following commands run in order:
deno test --coverage=./cov_data
deno coverage ./cov_data --reporter=lcov

What is the expected output?
medium
A. Tests run but no coverage data is saved
B. A coverage report file in lcov format is generated
C. An error occurs because coverage directory is missing
D. Coverage report is printed directly in the terminal

Solution

  1. Step 1: Run tests with coverage saved to a directory

    The first command runs tests and saves coverage data into the folder ./cov_data.
  2. Step 2: Generate coverage report in lcov format

    The second command reads coverage data from ./cov_data and outputs a report in lcov format to a file (stdout is the report content, but typically redirected to a file).
  3. Final Answer:

    A coverage report file in lcov format is generated -> Option B
  4. Quick Check:

    Coverage data saved + lcov report generated [OK]
Hint: Save coverage data first, then generate report from it [OK]
Common Mistakes:
  • Expecting coverage report without saving data first
  • Thinking lcov generates a file automatically (use redirection)
  • Assuming error if directory exists
4. You ran deno test --coverage but deno coverage shows no data. What is the likely cause?
medium
A. Your test files have syntax errors
B. You forgot to specify a coverage directory when running tests
C. You ran deno coverage before running tests
D. Coverage data is automatically deleted after tests

Solution

  1. Step 1: Understand coverage data flow

    Coverage data is collected when tests run with coverage enabled and saved to a directory or default location.
  2. Step 2: Check command order

    If deno coverage is run before tests, no coverage data exists yet, so it shows no data.
  3. Final Answer:

    You ran deno coverage before running tests -> Option C
  4. Quick Check:

    Run tests first, then coverage report [OK]
Hint: Always run tests with coverage before viewing reports [OK]
Common Mistakes:
  • Assuming coverage directory is mandatory every time
  • Thinking syntax errors cause no coverage data
  • Believing coverage data auto-deletes after tests
5. You want to generate a coverage report in HTML format and open it in your browser. Which sequence of commands achieves this correctly?
hard
A. deno test --coverage=./cov_data && deno coverage ./cov_data --reporter=html && open coverage/index.html
B. deno coverage --reporter=html && deno test --coverage && open ./cov_data/index.html
C. deno test && deno coverage --reporter=html && open ./cov_data/index.html
D. deno test --coverage && deno coverage --reporter=html > report.html && open report.html

Solution

  1. Step 1: Run tests with coverage saved to a directory

    Use deno test --coverage=./cov_data to run tests and save coverage data in ./cov_data.
  2. Step 2: Generate HTML report from saved coverage data

    Run deno coverage ./cov_data --reporter=html to create HTML files inside coverage/ directory.
  3. Step 3: Open the generated HTML report in browser

    Use open coverage/index.html (macOS) or equivalent to view the report.
  4. Final Answer:

    deno test --coverage=./cov_data && deno coverage ./cov_data --reporter=html && open coverage/index.html -> Option A
  5. Quick Check:

    Save coverage, generate HTML, then open file [OK]
Hint: Save coverage, generate HTML report, then open it [OK]
Common Mistakes:
  • Generating report before running tests
  • Not specifying coverage directory consistently
  • Redirecting HTML output to file instead of directory
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