yoklainterview sim

Frontend Javascript Testing Tooling Interview Questions

75 verified Frontend Javascript Testing Tooling interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Javascript Testing ToolingDifficulty 1
In Jest/Vitest, what is the basic purpose of describe() versus it()/test()?
  • aThey are interchangeable aliases for the same function
  • bdescribe() runs tests in parallel; it()/test() runs them sequentially
  • cdescribe() groups tests; it()/test() defines one test case
  • ddescribe() defines an individual test case; it()/test() groups them
Explanation:describe() is a grouping block used to organize related tests (and share setup via hooks), while it()/test() defines one actual test case with an assertion. They are not aliases (a), neither controls execution parallelism on its own (b), and (d) reverses the actual roles — grouping belongs to describe(), individual cases to it()/test().
Javascript Testing ToolingDifficulty 1
What is the difference between expect(x).toBe(y) and expect(x).toEqual(y)?
  • atoBe uses Object.is (reference equality); toEqual compares values deeply
  • bThere is no difference; both always compare deeply
  • ctoBe is for numbers only; toEqual is for strings only
  • dtoEqual checks reference equality; toBe checks deep value equality
Explanation:toBe compares with Object.is — identical primitives or the exact same object reference. toEqual walks the structure recursively and compares values, so two different objects with the same shape are equal under toEqual but not toBe.
Javascript Testing ToolingDifficulty 1
What does a beforeEach(fn) inside a describe block do?
  • aRuns fn once before all tests in that block start
  • bSkips the next test if fn throws
  • cRuns fn only before the first test in that block
  • dRuns fn before every test, each time freshly
Explanation:beforeEach re-runs its callback before every single test in the enclosing block, which is exactly what makes it useful for resetting fresh state between tests. Running once for the whole block is beforeAll's job, not beforeEach's (a, c).
Javascript Testing ToolingDifficulty 1
In a test file with test.only('a', ...), test('b', ...), and test('c', ...), which tests actually run?
  • aAll three tests run
  • bOnly test 'a' runs; 'b' and 'c' are skipped
  • cOnly 'b' and 'c' run; 'a' is skipped
  • dtest.only throws an error unless every test in the file uses it
Explanation:.only restricts the run to just the marked test(s) in that file, skipping every other test — useful for focusing on one case while debugging. It doesn't require universal use (d) or invert which test is selected (c).
Javascript Testing ToolingDifficulty 1
In package.json, a dependency listed as "^1.2.3" allows npm to install which range of versions?
  • aOnly exactly version 1.2.3
  • bAny version, including 2.x.x and above
  • cAny 1.x.x version that is >= 1.2.3 and < 2.0.0
  • dAny version >= 1.2.3 and < 1.3.0 only
Explanation:The caret (^) allows updates that don't change the leftmost non-zero digit — so ^1.2.3 permits anything from 1.2.3 up to (but not including) 2.0.0. Restricting to only the patch range (d) is what a tilde (~1.2.3) does instead.
Javascript Testing ToolingDifficulty 1
What is the purpose of the "scripts" field in package.json?
  • aIt defines named shell commands runnable via npm run <name>
  • bIt declares production dependencies required at runtime
  • cIt configures the test framework's matcher functions
  • dIt lists which files should be published to npm
Explanation:"scripts" maps short names to shell commands, so npm run test or npm run build invoke whatever command string is registered under that name. Dependencies live under "dependencies"/"devDependencies" (b), and published files are controlled by "files" or .npmignore (d).

Test yourself against the 2925-question Frontend bank.

Start interview