All jobs / Frontend / web developer / Testing

Frontend / web developer interview question · 1–3 years

A test passes when run alone and fails when the whole file runs, and the failing test changes when you reorder them.

What do you look for?

The strongest answer

Shared state leaking between tests: a module-level variable, a mock never reset, storage or timers left over. Reset in beforeEach or afterEach and build fresh data per test so order cannot matter

Why it works

Right — order dependence means tests share something. Isolation is the rule: each test sets up and tears down its own world.

What a good answer covers

Answers that fall short

Who gets asked this

More Testing questions