All quizzesHard
E2E & Performance Testing
Preview — 3 of 10 questions
What does the testing pyramid suggest about test distribution?
javascript
E2E Tests (5-10%)
/\
/ \
/ \
/ Integ\
/ Tests\
/ (15-30%)\
/___________\
Unit Tests
(60-80%)AMany unit tests (base), fewer integration tests (middle), fewer end-to-end tests (top).
BWrite equal numbers of unit, integration, and end-to-end tests.
CMost tests should be end-to-end tests.
DTesting pyramid is outdated.
What is snapshot testing?
javascript
// First run: Snapshot is created
test("should render user profile", () => {
const profile = renderUserProfile({ name: "Alice", age: 30 });
expect(profile).toMatchSnapshot();
// Snapshot created with current output
});
// Snapshot file (created automatically)
// __snapshots__/user.test.js.snap
/*
exports[`should render user profile 1`] = `
<div>
<h1>Alice</h1>
<p>Age: 30</p>
</div>
`;
*/
// Future runs: Compare against snapshot
// If output changes, test fails and shows diffATaking a screenshot of the UI.
BA backup of your test files.
CTesting only image files.
DCapturing the output of a function and comparing future outputs to it.
What tools can you use to debug JavaScript performance issues?
javascript
performance.mark("start");
// Code to measure
performance.mark("end");
performance.measure("duration", "start", "end");
const measure = performance.getEntriesByName("duration")[0];
console.log(`Duration: ${measure.duration}ms`);AConsole.log is enough.
BPerformance issues cannot be debugged.
CPerformance API, Lighthouse, DevTools profiler, WebPageTest.
DOnly browser extensions.
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.