Complete the code to clear cookies after each test in Cypress.
afterEach(() => {
cy.[1]();
});The clearCookies command clears all cookies, ensuring a clean state after each test.
Complete the code to reset the database before each test using a custom Cypress task.
beforeEach(() => {
cy.task('[1]');
});The custom task resetDb is commonly used to reset the database state before tests.
Fix the error in the code to delete a user via API after each test.
afterEach(() => {
cy.request('DELETE', '/api/users/[1]');
});The API expects the parameter userId to identify which user to delete.
Fill both blanks to clear local storage and session storage before each test.
beforeEach(() => {
cy.window().then(win => {
win.[1]();
win.[2]();
});
});To clear storage in the browser window, call localStorage.clear() and sessionStorage.clear().
Fill all three blanks to create a custom command that resets test data by calling an API and clearing cookies.
Cypress.Commands.add('resetTestData', () => { cy.request('[1]', '/api/reset'); cy.[2](); cy.[3](); });
The reset API is called with a POST request. Then cookies and local storage are cleared using clearCookies() and clearLocalStorage().