Skip to content
๐Ÿงช

Testing & Debugging

150 exercises

Practice exercises for testing & debugging.

  1. 1

    What Is Automated Testing?

    Identify the core purpose of automated testing in software development.

    Multiple Choice Beginner
  2. 2

    Unit vs Integration Tests

    Distinguish between unit tests and integration tests by scope.

    Multiple Choice Easy
  3. 3

    Arrange-Act-Assert Pattern

    Recognize the three phases of the AAA test pattern.

    Multiple Choice Easy
  4. 4

    Test Suite and Test Case

    Understand the relationship between test suites and test cases.

    Multiple Choice Beginner
  5. 5

    Assertion Basics

    Identify what an assertion does in a test.

    Multiple Choice Beginner
  6. 6

    Jest test() Function

    Understand the basic Jest test() function signature.

    Multiple Choice Easy
  7. 7

    expect() Matchers

    Identify valid Jest matchers for expect().

    Multiple Choice Easy
  8. 8

    Purpose of Mocks

    Understand why mocks are used in unit tests.

    Multiple Choice Medium
  9. 9

    Spy vs Stub

    Differentiate between spies and stubs in testing.

    Multiple Choice Medium
  10. 10

    TDD Red-Green-Refactor

    Identify the three phases of the TDD cycle.

    Multiple Choice Medium
  11. 11

    100% Coverage Meaning

    Understand what 100% code coverage actually guarantees.

    Multiple Choice Medium
  12. 12

    Testing Async Functions

    Know how to test asynchronous functions in Jest.

    Multiple Choice Medium
  13. 13

    beforeEach vs beforeAll

    Distinguish between beforeEach and beforeAll hooks.

    Multiple Choice Medium
  14. 14

    Snapshot Testing Use Case

    Understand when snapshot testing is most useful.

    Multiple Choice Medium
  15. 15

    E2E Testing Tools

    Identify popular end-to-end testing tools.

    Multiple Choice Easy
  16. 16

    Test Pyramid Layers

    Understand the structure of the test pyramid.

    Multiple Choice Medium
  17. 17

    Parameterized Tests

    Understand the benefit of parameterized (table-driven) tests.

    Multiple Choice Medium
  18. 18

    CI Testing Purpose

    Understand the role of tests in continuous integration.

    Multiple Choice Easy
  19. 19

    React Testing Library

    Understand the philosophy of React Testing Library.

    Multiple Choice Medium
  20. 20

    BDD vs TDD

    Distinguish between BDD and TDD approaches.

    Multiple Choice Medium
  21. 21

    Predict toBe Result

    Predict the outcome of a Jest toBe assertion.

    Predict Output Beginner
  22. 22

    Predict toEqual with Objects

    Predict whether toEqual passes for two identical objects.

    Predict Output Easy
  23. 23

    Predict toBe with Objects

    Predict whether toBe passes for two identical-looking objects.

    Predict Output Easy
  24. 24

    Predict toContain Result

    Predict the result of a toContain assertion on an array.

    Predict Output Easy
  25. 25

    Predict toBeNull

    Predict the result of a toBeNull assertion.

    Predict Output Beginner
  26. 26

    Predict toBeUndefined

    Predict the result of a toBeUndefined assertion.

    Predict Output Beginner
  27. 27

    Predict toBeTruthy

    Predict the result of a toBeTruthy assertion on 0.

    Predict Output Easy
  28. 28

    Predict toHaveLength

    Predict the result of a toHaveLength assertion.

    Predict Output Easy
  29. 29

    Predict toThrow

    Predict the result of a toThrow assertion.

    Predict Output Medium
  30. 30

    Predict toBeGreaterThan

    Predict the result of a toBeGreaterThan assertion.

    Predict Output Easy
  31. 31

    Predict Mock Return Value

    Predict the output of a mocked function call.

    Predict Output Medium
  32. 32

    Predict Mock Call Count

    Predict the number of times a mock was called.

    Predict Output Medium
  33. 33

    Predict Spy Call Arguments

    Predict the arguments recorded by a spy.

    Predict Output Medium
  34. 34

    Predict toMatchObject

    Predict the result of a toMatchObject assertion.

    Predict Output Medium
  35. 35

    Predict toBeFalsy

    Predict the result of a toBeFalsy assertion on empty string.

    Predict Output Easy
  36. 36

    Predict toBeInstanceOf

    Predict the result of a toBeInstanceOf assertion.

    Predict Output Easy
  37. 37

    Predict toHaveBeenCalledWith

    Predict the result of a toHaveBeenCalledWith assertion.

    Predict Output Medium
  38. 38

    Predict string toMatch

    Predict the result of a regex toMatch assertion.

    Predict Output Medium
  39. 39

    Predict toBeLessThan

    Predict the result of a toBeLessThan assertion.

    Predict Output Easy
  40. 40

    Predict Nested toEqual

    Predict the result of a deep equality check with nested objects.

    Predict Output Medium
  41. 41

    Fill: test() Function

    Complete the Jest test function syntax.

    Fill in the Blank Beginner
  42. 42

    Fill: expect Matcher

    Complete the Jest assertion with the correct matcher.

    Fill in the Blank Beginner
  43. 43

    Fill: describe Block

    Complete the Jest describe block syntax.

    Fill in the Blank Beginner
  44. 44

    Fill: beforeEach Hook

    Complete the Jest hook that runs before each test.

    Fill in the Blank Easy
  45. 45

    Fill: afterEach Hook

    Complete the Jest hook that runs after each test.

    Fill in the Blank Easy
  46. 46

    Fill: jest.fn()

    Complete the code to create a mock function.

    Fill in the Blank Easy
  47. 47

    Fill: mockReturnValue

    Complete the code to set a mock's return value.

    Fill in the Blank Medium
  48. 48

    Fill: TDD First Step

    Complete the first step of the TDD cycle.

    Fill in the Blank Medium
  49. 49

    Fill: Coverage Tool

    Complete the Jest coverage flag.

    Fill in the Blank Easy
  50. 50

    Fill: async/await Test

    Complete the async test syntax.

    Fill in the Blank Medium
  51. 51

    Fill: toContain

    Complete the matcher to check array membership.

    Fill in the Blank Easy
  52. 52

    Fill: toEqual

    Complete the matcher for deep equality.

    Fill in the Blank Easy
  53. 53

    Fill: toThrow

    Complete the matcher to check if a function throws.

    Fill in the Blank Medium
  54. 54

    Fill: jest.spyOn

    Complete the code to spy on a method.

    Fill in the Blank Medium
  55. 55

    Fill: toMatchSnapshot

    Complete the snapshot testing matcher.

    Fill in the Blank Medium
  56. 56

    Fill: test.each

    Complete the parameterized test syntax.

    Fill in the Blank Medium
  57. 57

    Fill: toBeDefined

    Complete the matcher to check a value is defined.

    Fill in the Blank Easy
  58. 58

    Fill: test.skip

    Complete the code to skip a test.

    Fill in the Blank Easy
  59. 59

    Fill: toHaveBeenCalled

    Complete the matcher to check a mock was called.

    Fill in the Blank Medium
  60. 60

    Fill: toHaveBeenCalledTimes

    Complete the matcher to check call count.

    Fill in the Blank Medium
  61. 61

    Mistake: Missing Assertion

    Find the mistake in a test that lacks an assertion.

    Find the Mistake Beginner
  62. 62

    Mistake: toBe on Object

    Find the mistake using toBe for object comparison.

    Find the Mistake Easy
  63. 63

    Mistake: Missing await

    Find the mistake in an async test missing await.

    Find the Mistake Medium
  64. 64

    Mistake: toThrow Called Directly

    Find the mistake in a toThrow assertion.

    Find the Mistake Medium
  65. 65

    Mistake: Shared Mutable State

    Find the mistake with shared state between tests.

    Find the Mistake Medium
  66. 66

    Mistake: Not Restoring Mock

    Find the mistake with an unrestored spy.

    Find the Mistake Medium
  67. 67

    Mistake: Testing Floating Point

    Find the mistake with floating-point comparison.

    Find the Mistake Medium
  68. 68

    Mistake: Multiple Assertions

    Find the mistake with testing multiple unrelated things.

    Find the Mistake Medium
  69. 69

    Mistake: Wrong Matcher Name

    Find the mistake with an incorrect matcher.

    Find the Mistake Beginner
  70. 70

    Mistake: Missing done Callback

    Find the mistake with a callback-based async test.

    Find the Mistake Medium
  71. 71

    Mistake: Testing Implementation

    Find the mistake with testing internal implementation.

    Find the Mistake Medium
  72. 72

    Mistake: Async in beforeEach

    Find the mistake with async setup.

    Find the Mistake Medium
  73. 73

    Mistake: Blindly Updating Snapshot

    Find the mistake with snapshot updating.

    Find the Mistake Medium
  74. 74

    Mistake: Meaningless Test Name

    Find the mistake with a poor test description.

    Find the Mistake Easy
  75. 75

    Mistake: Mocking Too Much

    Find the mistake with over-mocking.

    Find the Mistake Medium
  76. 76

    Mistake: Comparing NaN

    Find the mistake with NaN comparison.

    Find the Mistake Medium
  77. 77

    Mistake: Chasing 100% Coverage

    Find the mistake with a coverage-focused approach.

    Find the Mistake Medium
  78. 78

    Mistake: Test Depends on Order

    Find the mistake with order-dependent tests.

    Find the Mistake Medium
  79. 79

    Mistake: Using toBe for Array

    Find the mistake with array comparison.

    Find the Mistake Easy
  80. 80

    Mistake: Hardcoded Time in Test

    Find the mistake with time-dependent testing.

    Find the Mistake Medium
  81. 81

    Concept: Why Test?

    Check understanding of the value of automated testing.

    Concept Check Beginner
  82. 82

    Concept: Test Types Hierarchy

    Check understanding of the testing hierarchy.

    Concept Check Easy
  83. 83

    Concept: Isolation in Unit Tests

    Check understanding of test isolation.

    Concept Check Easy
  84. 84

    Concept: TDD Benefits

    Check understanding of TDD advantages.

    Concept Check Medium
  85. 85

    Concept: When to Mock

    Check understanding of appropriate mocking scenarios.

    Concept Check Medium
  86. 86

    Concept: Coverage Types

    Check understanding of different coverage metrics.

    Concept Check Medium
  87. 87

    Concept: E2E Test Cost

    Check understanding of E2E test trade-offs.

    Concept Check Medium
  88. 88

    Concept: Integration Test Scope

    Check understanding of what integration tests verify.

    Concept Check Easy
  89. 89

    Concept: Query by Role

    Check understanding of React Testing Library queries.

    Concept Check Medium
  90. 90

    Concept: Snapshot Files

    Check understanding of snapshot file management.

    Concept Check Medium
  91. 91

    Concept: CI Test Speed

    Check understanding of CI test optimization.

    Concept Check Medium
  92. 92

    Concept: Given-When-Then

    Check understanding of BDD scenario structure.

    Concept Check Medium
  93. 93

    Concept: Test Independence

    Check understanding of why tests should be independent.

    Concept Check Easy
  94. 94

    Concept: Test Doubles Types

    Check understanding of different test double types.

    Concept Check Medium
  95. 95

    Concept: Testing Promises

    Check understanding of promise testing approaches.

    Concept Check Medium
  96. 96

    Concept: jsdom Environment

    Check understanding of the jsdom test environment.

    Concept Check Medium
  97. 97

    Concept: Shallow vs Deep Render

    Check understanding of shallow vs deep component rendering.

    Concept Check Medium
  98. 98

    Concept: AAA Pattern Benefit

    Check understanding of the Arrange-Act-Assert pattern.

    Concept Check Easy
  99. 99

    Concept: Flaky Tests

    Check understanding of flaky tests.

    Concept Check Medium
  100. 100

    Concept: Test as Documentation

    Check understanding of tests as living documentation.

    Concept Check Easy
  101. 101

    Unit Test Purpose

    What is a unit test?

    Multiple Choice Beginner
  102. 102

    Integration Test

    What does an integration test verify?

    Multiple Choice Easy
  103. 103

    E2E Test

    What is an end-to-end (E2E) test?

    Multiple Choice Easy
  104. 104

    Test Pyramid

    What is the test pyramid?

    Multiple Choice Easy
  105. 105

    Jest test Function

    What does the test() function do in Jest?

    Multiple Choice Beginner
  106. 106

    Expect Function

    What does expect() do in Jest?

    Multiple Choice Beginner
  107. 107

    toBe vs toEqual

    What is the difference between toBe and toEqual?

    Multiple Choice Easy
  108. 108

    describe Block

    What does describe() do in Jest?

    Multiple Choice Beginner
  109. 109

    beforeEach Purpose

    What does beforeEach do?

    Multiple Choice Easy
  110. 110

    Mock Purpose

    What is a mock in testing?

    Multiple Choice Easy
  111. 111

    Spy vs Stub

    How does a spy differ from a stub?

    Multiple Choice Medium
  112. 112

    TDD Cycle

    What are the three steps of TDD?

    Multiple Choice Easy
  113. 113

    Async Test

    How do you test async functions in Jest?

    Multiple Choice Easy
  114. 114

    Snapshot Test

    What does a snapshot test do?

    Multiple Choice Medium
  115. 115

    Coverage Metric

    What does code coverage measure?

    Multiple Choice Easy
  116. 116

    Test Isolation

    Why is test isolation important?

    Multiple Choice Easy
  117. 117

    Parameterized Test

    What is a parameterized test?

    Multiple Choice Easy
  118. 118

    BDD Style

    What is BDD in testing?

    Multiple Choice Medium
  119. 119

    React Testing Library

    What is React Testing Library?

    Multiple Choice Medium
  120. 120

    Assertion Throw

    How do you test that a function throws an error?

    Multiple Choice Easy
  121. 121

    Mock Module

    What does jest.mock() do?

    Multiple Choice Medium
  122. 122

    Test Double Types

    What are the types of test doubles?

    Multiple Choice Medium
  123. 123

    CI Testing

    What is the role of testing in CI/CD?

    Multiple Choice Easy
  124. 124

    Test Naming

    What is a good test name convention?

    Multiple Choice Easy
  125. 125

    Flaky Test

    What is a flaky test and why is it harmful?

    Multiple Choice Medium
  126. 126

    DOM Testing

    What is DOM testing?

    Multiple Choice Medium
  127. 127

    Test Setup Files

    What is a Jest setup file?

    Multiple Choice Medium
  128. 128

    Testing Types

    What are the main types of software testing?

    Multiple Choice Medium
  129. 129

    Mutation Testing

    What is mutation testing?

    Multiple Choice Medium
  130. 130

    Test Refactoring

    When should you refactor tests?

    Multiple Choice Medium
  131. 131

    toBe Pass

    Predict the output.

    Predict Output Beginner
  132. 132

    toBe Fail

    Predict the output.

    Predict Output Beginner
  133. 133

    toEqual Object

    Predict the output.

    Predict Output Easy
  134. 134

    toBe Object Fail

    Predict the output.

    Predict Output Easy
  135. 135

    toHaveLength

    Predict the output.

    Predict Output Easy
  136. 136

    toContain

    Predict the output.

    Predict Output Easy
  137. 137

    toThrow

    Predict the output.

    Predict Output Easy
  138. 138

    toBeTruthy

    Predict the output.

    Predict Output Beginner
  139. 139

    toBeFalsy

    Predict the output.

    Predict Output Beginner
  140. 140

    not Modifier

    Predict the output.

    Predict Output Easy
  141. 141

    Mock Called

    Predict the output.

    Predict Output Easy
  142. 142

    Mock Call Count

    Predict the output.

    Predict Output Easy
  143. 143

    Mock Return Value

    Predict the output.

    Predict Output Easy
  144. 144

    Async Await

    Predict the output.

    Predict Output Easy
  145. 145

    beforeEach Run

    Predict the output.

    Predict Output Easy
  146. 146

    test.each

    Predict the output.

    Predict Output Medium
  147. 147

    String Matcher

    Predict the output.

    Predict Output Easy
  148. 148

    Object Keys

    Predict the output.

    Predict Output Medium
  149. 149

    Resolve Promise

    Predict the output.

    Predict Output Medium
  150. 150

    Reject Promise

    Predict the output.

    Predict Output Medium

Build real projects

Apply what you learned by building guided projects with starter code and solutions.

View projects