[{"id":"cypressbeginner-001","courseId":"cypress-beginner","domain":"test-structure","topic":"describe and it blocks","prompt":"You have three checks about a login form and want them grouped under one heading in the test output. Which use of the test blocks does that?","hint":"One block groups related checks; the other holds a single check.","explain":"Test code is layered. One kind of wrapper collects related cases under a heading, and another kind holds a single case with its assertions. The titles you give each one appear in the output.","source":"https://docs.cypress.io/app/core-concepts/writing-and-organizing-tests","interaction":{"type":"single"},"options":[{"id":"a","text":"describe() groups related checks; it() defines each individual check","why":"describe() is the grouping block, and it() defines one individual test inside it."},{"id":"b","text":"it() groups related checks; describe() defines each individual check","whyNot":"The roles are reversed: describe() groups related tests and it() defines a single test."},{"id":"c","text":"A single it() wrapping all three checks","whyNot":"All three would run as one test, so a failure would not show which check broke."},{"id":"d","text":"Three separate describe() blocks, one for each check","whyNot":"describe() is for grouping; each check needs its own it() to be a test."}],"answer":"a","explanation":"describe() (or context()) groups related tests under a heading, and it() (or specify()) defines one individual test. Good titles tell a teammate what broke.","concept":"describe() (or context()) groups related tests under a heading, and it() (or specify()) defines one individual test. Good titles tell a teammate what broke.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Use describe() to group and it() to define; a title should say what broke."]},{"id":"cypressbeginner-002","courseId":"cypress-beginner","domain":"test-structure","topic":"beforeEach setup hooks","prompt":"A spec has one test, with a before() hook, a beforeEach() hook, an afterEach() hook and an after() hook around it. Put these steps of a spec run in the order Cypress performs them.","hint":"Setup for the whole group comes first, and cleanup mirrors it on the way out.","explain":"A test's surroundings come in layers. Some setup wraps the whole group, some wraps each case, and the case sits in the middle. Cleanup unwinds those layers in the opposite direction.","source":"https://docs.cypress.io/app/core-concepts/writing-and-organizing-tests","interaction":{"type":"sort","items":[{"text":"All before() hooks run (once)","why":"Setup for the whole group runs a single time before anything else."},{"text":"Any beforeEach() hooks run","why":"Per-test setup runs before each test, after the group-level setup is done."},{"text":"Tests run","why":"The test itself starts only after its setup is in place."},{"text":"Any afterEach() hooks run","why":"Per-test cleanup runs once each test has finished."},{"text":"All after() hooks run (once)","why":"Final teardown for the whole group runs last, after every test is done."}]},"options":[],"answer":"o:abcde","explanation":"Cypress runs before() hooks once, then beforeEach() hooks, then the tests, then afterEach() hooks, and after() hooks once at the end.","concept":"Cypress runs before() hooks once, then beforeEach() hooks, then the tests, then afterEach() hooks, and after() hooks once at the end.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Put per-test setup in beforeEach() and whole-group setup in before()."]},{"id":"cypressbeginner-003","courseId":"cypress-beginner","domain":"test-structure","topic":"Spec file naming and location","prompt":"A file named cypress/e2e/login.js sits in the cypress/e2e folder, so Cypress loads it as a spec by default.","hint":"Look at the file name, not just the folder it sits in.","explain":"Cypress matches each file name against a pattern before loading anything. Helper files can share the same folder, so the exact naming convention decides which files run.","source":"https://docs.cypress.io/app/core-concepts/writing-and-organizing-tests","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Folder location is not enough; login.js lacks the .cy. infix that the default pattern needs."},{"id":"b","text":"False","why":"The default pattern needs the .cy. infix, so login.js is never discovered and never runs."}],"answer":"b","explanation":"Cypress loads only files that match specPattern. By default e2e specs need the .cy. infix, so a file named login.js is not discovered.","concept":"Cypress loads only files that match specPattern. By default e2e specs need the .cy. infix, so a file named login.js is not discovered.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["If a spec does not appear, check that its filename matches specPattern."]},{"id":"cypressbeginner-004","courseId":"cypress-beginner","domain":"test-structure","topic":"Test isolation between tests","prompt":"With test isolation on, Cypress clears cookies and storage before each test. A spec needs a consent cookie and a logged-in user in every test. Which TWO approaches keep both working?","hint":"Consider what the reset empties before each test, and what a test can still do to get that data back.","explain":"Each test starts in a fresh browser context: cookies and the two web storage areas are emptied first, so data from a previous test is gone. Other storage, such as IndexedDB, is never emptied.","source":"https://docs.cypress.io/app/core-concepts/test-isolation","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Call cy.setCookie() in a beforeEach hook","why":"beforeEach runs before every test, so the cookie is present at the start of each one."},{"id":"b","text":"Restore a logged-in state with cy.session()","why":"cy.session() caches the cookies and storage from its first run and restores them for later tests."},{"id":"c","text":"Set the cookie once in a before() hook","whyNot":"before() runs once, but isolation clears cookies before each test, so the cookie is gone by the next test."},{"id":"d","text":"Call cy.clearCookies() in a beforeEach hook","whyNot":"clearCookies() removes cookies; it cannot keep one alive for the next test."},{"id":"e","text":"Pass testIsolation: false to each cy.visit()","whyNot":"testIsolation is a global or describe-level setting, not an option of cy.visit()."},{"id":"f","text":"Rely on the cookie left by the previous test","whyNot":"Isolation clears cookies before each test, so the previous test's cookie is already gone."}],"answer":"ab","explanation":"With testIsolation on, cookies, localStorage and sessionStorage are cleared before each test. Re-setting a cookie in beforeEach and caching a login with cy.session() keep state available.","concept":"With testIsolation on, cookies, localStorage and sessionStorage are cleared before each test. Re-setting a cookie in beforeEach and caching a login with cy.session() keep state available.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Isolation clears cookies and storage per test; re-create or cache them on purpose."]},{"id":"cypressbeginner-005","courseId":"cypress-beginner","domain":"test-structure","topic":"Aliases with as()","prompt":"Inside one test, you run cy.get('.row').first().as('firstRow'). Later in the same test you need that row again. Which command reads it?","hint":"Aliases are looked up by name through the same command you use for selectors.","explain":"Cypress runs commands later, so a result cannot simply be kept in an ordinary variable. You store it under a name you choose, and the name lasts only for the test that created it.","source":"https://docs.cypress.io/app/core-concepts/variables-and-aliases","interaction":{"type":"single"},"options":[{"id":"a","text":"cy.get('@firstRow')","why":"The @ prefix tells cy.get() to look up the alias and re-run its stored query."},{"id":"b","text":"cy.get('firstRow')","whyNot":"Without @, the text is read as a CSS selector, so this looks for a firstRow element."},{"id":"c","text":"cy.get('.firstRow')","whyNot":"The dot makes it a class selector; an alias is not a CSS class."},{"id":"d","text":"cy.alias('firstRow')","whyNot":"Aliases are read through cy.get() with the @ prefix, not through a separate command."}],"answer":"a","explanation":"Aliases created with .as() are read back with cy.get() and an @ prefix. They are cleaned up automatically after each test.","concept":"Aliases created with .as() are read back with cy.get() and an @ prefix. They are cleaned up automatically after each test.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Read an alias with cy.get('@name'); it is cleared after the test ends."]}]