Web Testing & Debugging MCQs for the NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Web testing checks automatically that a site behaves as specified, through unit, integration and end-to-end (E2E) tests, while debugging finds the cause of a failure, mostly with the browser's developer tools (DevTools). It is the 14th of the 17 topics in the Web Development area, which carries 10% of the NSCT according to HEC's Areas of Competencies.

HEC's NSCT report shows analysis questions had the lowest accuracy nationally (44.8%), and this topic is rich in them: a flaky test, a CORS error or a leak to diagnose. Most code here is JavaScript, so revise promises and the event loop too.

DevTools

Browser developer tools (F12 in Chrome, Edge and Firefox) let you inspect and pause a running page. Know what each panel is for:

Panel Use it to
Elements Inspect the live DOM, edit CSS, see event listeners
Console Read errors, run JavaScript, console.table, console.assert
Sources Set breakpoints, step through code, use source maps
Network See each request's status, headers, payload, timing; throttle
Performance Record a trace to find long tasks and layout work
Memory Take heap snapshots to find leaks
Application Cookies, localStorage, IndexedDB, service workers

Breakpoints and stepping

A line breakpoint pauses at a line. A conditional breakpoint pauses only when an expression is true, for example i === 99. A logpoint logs without pausing. DOM change breakpoints pause when an element's subtree or attributes change, and event listener breakpoints pause in any handler for an event such as click. The debugger; statement is a breakpoint written in code.

While paused, step over runs a call as one step, step into enters the function, and step out finishes the current function.

Exam angle: "which panel" questions are easy marks. Network shows the request and response; Application shows storage.

Unit and end-to-end testing

A unit test checks one function or component in isolation. An integration test checks several parts working together, such as a route and its database. An E2E test drives a real browser through a full user flow.

Unit Integration End-to-end
Scope One function A few modules Whole app
Speed Milliseconds Hundreds of ms Seconds
Typical tools Jest, Vitest, Mocha Jest with a test DB, Supertest Playwright, Cypress, Selenium
How many Many Some Few

The testing pyramid keeps many fast unit tests at the base and few slow, brittle E2E tests on top. Its upside-down version, the "ice-cream cone", gives slow and flaky builds.

Test doubles replace real dependencies. Following Meszaros and Fowler, a stub returns canned data, a mock also verifies that expected calls happened, a fake is a simpler working version (such as an in-memory database) and a dummy is only a placeholder. Frameworks often call everything a "mock", so read the definition in the question.

Code coverage reports what ran: statement coverage counts executed statements, and branch coverage counts true and false outcomes. With 18 of 20 statements and 3 of 4 branches executed, coverage is 90% and 75%. Coverage measures execution, not correctness.

In TDD (test-driven development) you cycle red (write a failing test), green (make it pass), refactor. Regression testing reruns the suite after every change.

Exam angle: an assertion that runs before a promise resolves tests nothing. Return or await the promise.

Common traps

Worked examples

1. Understanding. Which kind of test should be most numerous in a healthy suite? Answer: unit tests. They are fastest and most stable, so the pyramid puts them at the base.

2. Application. A loop runs 1,000 times and fails only when i is 734. How do you stop at that iteration without clicking Resume 734 times? Answer: add a conditional breakpoint with i === 734 on the line inside the loop.

3. Analysis. A test checks that getTotal() returns 0.6 for items priced 0.1, 0.2 and 0.3, using strict equality, and it fails. The code adds the prices correctly. What is wrong? Answer: in binary floating point, 0.1 + 0.2 + 0.3 is 0.6000000000000001, so strict equality fails. Assert with a tolerance (for example toBeCloseTo) or keep money in integer units such as paisa.

Practise

The quiz below has 100 questions on this topic, filterable by tier and difficulty.

Practise: 100 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. Which Chrome DevTools panel lets you inspect the live DOM and edit an element's CSS rules to see the effect immediately?

    1. Network
    2. Elements
    3. Application
    4. Memory
    Show answer

    Answer: B. Elements

    The Elements panel shows the current DOM tree with the Styles pane, where you can toggle or edit CSS rules and see the page update at once. Network lists requests, Application shows storage, and Memory takes heap snapshots.

  2. Which DevTools panel shows cookies, localStorage, sessionStorage and registered service workers?

    1. Elements
    2. Sources
    3. Performance
    4. Application
    Show answer

    Answer: D. Application

    The Application panel groups client-side storage (cookies, Web Storage, IndexedDB, Cache Storage) and service worker controls. Sources is for code and breakpoints, and Performance records runtime traces.

  3. What does a conditional breakpoint do?

    1. Pauses at that line only when a given expression is true
    2. Pauses at that line on every execution
    3. Logs a message without ever pausing
    4. Pauses whenever any exception is thrown
    Show answer

    Answer: A. Pauses at that line only when a given expression is true

    A conditional breakpoint attaches an expression, such as i === 99, and pauses only when it evaluates to true. That is ideal inside loops. A logpoint logs without pausing, and 'pause on exceptions' is a separate setting.

  4. What happens when JavaScript reaches a debugger; statement while DevTools is open?

    1. Execution pauses there, just like a breakpoint
    2. The page reloads with caching disabled
    3. The statement prints the call stack and continues
    4. A syntax error is thrown
    Show answer

    Answer: A. Execution pauses there, just like a breakpoint

    debugger; is a programmatic breakpoint: with DevTools open, execution stops at that line so you can inspect scope and step. With DevTools closed it has no effect. It must be removed before shipping.

  5. Execution is paused on the line total = calcTax(price);. What does 'Step into' do?

    1. Runs calcTax fully and pauses on the next line
    2. Runs to the end of the current function
    3. Resumes until the next breakpoint
    4. Enters calcTax and pauses at its first line
    Show answer

    Answer: D. Enters calcTax and pauses at its first line

    Step into follows the call into the function body. Step over runs the call as one step and stops on the next line, Step out finishes the current function, and Resume continues to the next breakpoint.

  6. What is a unit test?

    1. A test that drives the whole application through a real browser
    2. A manual check done by the client before release
    3. A test of one small piece of code, such as a function, in isolation from its dependencies
    4. A load test that measures requests per second
    Show answer

    Answer: C. A test of one small piece of code, such as a function, in isolation from its dependencies

    Unit tests check the smallest testable units, usually a function or component, with collaborators replaced by test doubles. They are fast and pinpoint failures. Driving the full app in a browser is end-to-end testing.

  7. What does an end-to-end (E2E) test check?

    1. One function with every dependency mocked
    2. A complete user flow through the real UI, backend and database, as a user would perform it
    3. Only that the code compiles
    4. The visual design against a mock-up, pixel by pixel
    Show answer

    Answer: B. A complete user flow through the real UI, backend and database, as a user would perform it

    E2E tests (for example with Cypress, Playwright or Selenium) automate a real browser through flows such as sign-up or checkout, exercising every layer together. They give high confidence but are slower and more brittle than unit tests.

  8. Why does the testing pyramid recommend many unit tests and few E2E tests?

    1. E2E tests cannot find real bugs
    2. Unit tests are fast, cheap and stable, while E2E tests are slow, costly to maintain and more prone to flakiness
    3. Unit tests cover the user interface better than E2E tests
    4. Testing frameworks cap the number of E2E tests
    Show answer

    Answer: B. Unit tests are fast, cheap and stable, while E2E tests are slow, costly to maintain and more prone to flakiness

    The pyramid (often credited to Mike Cohn) balances confidence and cost. Lower layers run in milliseconds and fail for one clear reason; E2E tests catch integration problems but take seconds each and break more easily, so you keep a thin layer of them on top.

  9. Which test double is set up with expectations about how it should be called and fails the test if those calls do not happen?

    1. Mock
    2. Stub
    3. Dummy
    4. Fake
    Show answer

    Answer: A. Mock

    In Meszaros's and Fowler's terms, a mock verifies behaviour: it checks that the expected calls were made. A stub only returns canned answers, a dummy is passed but never used, and a fake is a simpler working implementation such as an in-memory database. Many tools blur these names, so read the question's definition.

  10. What does 100% statement coverage guarantee?

    1. The code has no bugs
    2. Every if condition was tested both true and false
    3. Every possible input value was tested
    4. Every statement ran at least once during the tests, but not that every branch outcome was taken
    Show answer

    Answer: D. Every statement ran at least once during the tests, but not that every branch outcome was taken

    Statement coverage only records which lines executed. An if without an else can be fully covered by a test where the condition is true, leaving the false path untested; branch coverage would show 50%. Coverage measures execution, never correctness.

FAQs

What is the difference between unit testing and end-to-end testing?

A unit test checks one function or component alone, with dependencies replaced by stubs or mocks, and runs in milliseconds. An end-to-end test drives a real browser through a whole flow, such as login to checkout, across frontend, backend and database. It catches integration problems but is slower and more fragile.

Which DevTools panel should I open first when an API call fails?

Open the Network panel and select the request. It shows the status code, request headers, the payload you sent and the response body. Then check the Console for errors such as CORS blocks, and use the Sources panel to pause in the code that made the call.

Is Jest a unit-testing or an end-to-end tool?

Jest is mainly a unit and integration test runner for JavaScript. It runs in Node.js, often with a simulated DOM, and includes assertions, mocks and coverage. For true end-to-end tests in real browsers, teams use Playwright, Cypress or Selenium alongside it.

How do I make a flaky test reliable?

Find the source of non-determinism. Replace fixed sleeps with waits for a condition, give every test fresh data instead of shared state, replace real network calls with stubs in unit tests, and control time and randomness. Only quarantine a test while you fix it.

Next step

Continue with Deployment & Hosting, the next topic in HEC's order. You can also return to the Web Development MCQs hub or test yourself in an NSCT mock test.