[{"id":"jestbeginner-001","courseId":"jest-beginner","domain":"test-structure","topic":"Default test file patterns","prompt":"In watch mode, changing a file inside the .git folder re-runs your tests, unless you add that folder to watchPathIgnorePatterns.","hint":"Think about which folders the watcher already leaves alone before you add any configuration.","explain":"Watch mode re-runs tests when files change, but it does not react to every path the same way. A setting that lists ignored paths has its own built-in defaults, and you can add more patterns to it.","source":"https://jestjs.io/docs/configuration","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"The watcher ignores version control folders such as .git even with no setting, so changes there don't re-run tests."},{"id":"b","text":"False","why":"Even with watchPathIgnorePatterns empty, the watcher ignores changes to .git, .hg and .sl by default."}],"answer":"b","explanation":"With no configuration, watch mode ignores changes to version control folders (.git, .hg, .sl); other dot-prefixed files and folders are still watched.","concept":"With no configuration, watch mode ignores changes to version control folders (.git, .hg, .sl); other dot-prefixed files and folders are still watched.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Watch mode already skips version control folders; add watchPathIgnorePatterns only for your own noisy paths."]},{"id":"jestbeginner-002","courseId":"jest-beginner","domain":"test-structure","topic":"Writing tests with test and it","prompt":"A teammate writes this table-driven test and names it '.add($a, $b)'. What titles does Jest report for the two rows?","hint":"Look at what the placeholder reads: a property of each row, or a positional argument.","explain":"A table-driven test can build each title from its row's data. Field placeholders read properties of a row object; printf placeholders read positional arguments and don't mix with them.","source":"https://jestjs.io/docs/api","interaction":{"type":"single"},"options":[{"id":"a","text":"Each title fills in that row's a and b values, e.g. .add(1, 1).","why":"Field placeholders like $a read the matching property of each row object, so each title shows its own values."},{"id":"b","text":"Every title is the same literal text, .add($a, $b), because $ placeholders need the tagged template form.","whyNot":"$variable placeholders also work with the object-row form; the names are replaced for each row."},{"id":"c","text":"Jest appends the row number to every title automatically, e.g. .add(1, 1) #0.","whyNot":"Row numbers appear only where you ask for them with $#; Jest does not add them on its own."},{"id":"d","text":"Jest throws an error, because a plain string name cannot hold $variable placeholders.","whyNot":"A name string can hold $variable placeholders; they are filled in from the row object."}],"answer":"a","explanation":"In test.each, a $variable in the title is replaced by that property of each row object; $variable cannot be combined with printf formatting such as %i, except %%.","concept":"In test.each, a $variable in the title is replaced by that property of each row object; $variable cannot be combined with printf formatting such as %i, except %%.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"test.each([\n  { a: 1, b: 1 },\n  { a: 1, b: 2 },\n])('.add($a, $b)', ({ a, b }) => {\n  expect(a + b).toBeGreaterThan(0);\n});","takeaways":["Use $property placeholders for object rows and %i placeholders for array rows; don't mix the two in one title."]},{"id":"jestbeginner-003","courseId":"jest-beginner","domain":"test-structure","topic":"Grouping tests with describe","prompt":"A team wraps a group of tests in describe.skip while a feature is paused. Which TWO statements about that block are correct?","hint":"Separate what happens to the tests inside the block from what happens to the block's own callback.","explain":"A group of tests can be paused as one unit. Think about what that marker changes for the tests inside, and whether the code that defines the group is affected when the file loads.","source":"https://jestjs.io/docs/api","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"The describe callback still runs, so code placed directly inside the block still executes.","why":"The docs warn that the describe block still runs; only the tests inside it are skipped."},{"id":"b","text":"xdescribe is an alias that does the same thing as describe.skip.","why":"xdescribe is listed as an alias of describe.skip, so both skip the block's tests."},{"id":"c","text":"Its tests are moved to the end of the file and run last.","whyNot":"describe.skip doesn't reorder anything; the skipped tests are simply not run."},{"id":"d","text":"The describe callback is never called, so nothing inside it is evaluated.","whyNot":"The describe block still runs; it is the tests inside that are skipped."},{"id":"e","text":"Every test inside it needs its own test.skip, or it still runs.","whyNot":"describe.skip already skips the tests inside its block, so per-test markers aren't needed."},{"id":"f","text":"The block is removed from the file at build time, so its code is never loaded.","whyNot":"Nothing is removed at build time; the file is loaded and the describe callback runs."}],"answer":"ab","explanation":"describe.skip (alias xdescribe) skips the tests in the block, but the describe block itself still runs; setup that must also be skipped belongs in a beforeAll or beforeEach block.","concept":"describe.skip (alias xdescribe) skips the tests in the block, but the describe block itself still runs; setup that must also be skipped belongs in a beforeAll or beforeEach block.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["describe.skip skips the tests but not the describe body; keep setup that must be skipped in hooks."]},{"id":"jestbeginner-004","courseId":"jest-beginner","domain":"test-structure","topic":"beforeEach and afterEach hooks","prompt":"A test file has beforeAll, beforeEach and afterEach hooks at the top level, one top-level test, then a nested describe with its own beforeAll and one test. Each prints a label. Put these first five printed lines of the run in order.","hint":"Consider which setup runs once for the whole file and which runs around each individual test.","explain":"Setup and teardown callbacks belong to a scope, either the file or a block nested in it. Each runs at a moment tied to entering or leaving that scope, or to each unit of work inside it.","source":"https://jestjs.io/docs/setup-teardown","interaction":{"type":"sort","items":[{"text":"1 - beforeAll","why":"The top-level one-time setup is the first thing Jest runs in the file."},{"text":"1 - beforeEach","why":"Per-test setup for the top-level test runs just before that test."},{"text":"1 - test","why":"The top-level test runs once its setup is complete."},{"text":"1 - afterEach","why":"Teardown for that test runs after the test finishes."},{"text":"2 - beforeAll","why":"Entering the nested block triggers its one-time setup, after the top-level test is fully cleaned up."}]},"options":[],"answer":"o:abcde","explanation":"Hooks run in declaration order, and an outer beforeEach runs before an inner one; a nested block's beforeAll runs when Jest reaches that block, after the top-level test and its afterEach have finished.","concept":"Hooks run in declaration order, and an outer beforeEach runs before an inner one; a nested block's beforeAll runs when Jest reaches that block, after the top-level test and its afterEach have finished.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["beforeAll runs once when Jest reaches its scope; beforeEach runs before every test in its scope."]},{"id":"jestbeginner-005","courseId":"jest-beginner","domain":"test-structure","topic":"beforeAll and afterAll hooks","prompt":"Five tests in one file each query a shared database connection. Opening it takes an async call that must finish first. Which hook should open the connection?","hint":"Think about how often the setup needs to happen, not how many tests there are.","explain":"Some setup needs to happen only once for a whole file, rather than before every case. Hooks can return a promise, so asynchronous work can finish before dependent tests start.","source":"https://jestjs.io/docs/setup-teardown","interaction":{"type":"single"},"options":[{"id":"a","text":"beforeAll, which runs once before the file's tests begin","why":"beforeAll runs once before the tests in its scope, so a shared connection is opened one time."},{"id":"b","text":"beforeEach, which runs once before the first test only","whyNot":"beforeEach runs before every test, not just the first, so it would reopen the connection each time."},{"id":"c","text":"afterAll, which runs before the first test begins","whyNot":"afterAll runs after the tests finish, so it is for cleanup rather than opening a connection first."},{"id":"d","text":"Directly in the describe body, with an await at the top level","whyNot":"The docs say asynchronous setup can't simply be done inline, so a hook that returns the promise is used."}],"answer":"a","explanation":"beforeAll runs once before the tests in its scope and afterAll runs once after them; a hook that returns a promise makes Jest wait for that promise.","concept":"beforeAll runs once before the tests in its scope and afterAll runs once after them; a hook that returns a promise makes Jest wait for that promise.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Use beforeAll for shared setup that tests can reuse, and beforeEach when each test needs its own."]}]