Challenge - 5 Problems
Describe Blocks Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Purpose of describe blocks in Cypress tests
What is the main purpose of using
describe blocks in Cypress test files?Attempts:
2 left
💡 Hint
Think about how you organize chapters in a book to keep related topics together.
✗ Incorrect
describe blocks help group related tests logically. This makes test files easier to read and maintain. They do not control execution order or variable scope globally.
❓ Predict Output
intermediate2:00remaining
Output order of nested describe and it blocks
Consider this Cypress test code. What is the order of test names printed in the test runner?
Cypress
describe('Group A', () => { it('Test 1', () => {}); describe('Group B', () => { it('Test 2', () => {}); }); it('Test 3', () => {}); });
Attempts:
2 left
💡 Hint
Tests run in the order they appear inside their describe blocks, preserving nesting.
✗ Incorrect
The test runner shows full nested names. The order is Test 1, then nested Test 2 inside Group B, then Test 3.
❓ assertion
advanced2:00remaining
Correct assertion inside nested describe block
Which assertion correctly checks that a button with id
submitBtn is visible inside a nested describe block in Cypress?Cypress
describe('Form Tests', () => { describe('Submit Button', () => { it('should be visible', () => { // Which assertion is correct here? }); }); });
Attempts:
2 left
💡 Hint
Remember the correct Cypress command to select elements and check visibility.
✗ Incorrect
Option A uses the correct selector #submitBtn and the Cypress assertion should('be.visible'). Other options use invalid commands or selectors.
🔧 Debug
advanced2:00remaining
Why does a test inside describe block not run?
A developer wrote this code but the test inside
describe does not run. What is the reason?Cypress
describe('Login Tests', () => { it('should log in successfully', () => { cy.visit('/login'); cy.get('#username').type('user'); cy.get('#password').type('pass'); cy.get('#submit').click(); }); }); // Outside describe it('should log out', () => { cy.get('#logout').click(); });
Attempts:
2 left
💡 Hint
Both tests are valid and should run unless skipped or filtered.
✗ Incorrect
Both tests run normally. Tests inside and outside describe blocks run unless skipped or filtered. The describe block is correctly defined.
❓ framework
expert2:30remaining
Best practice for setup code in nested describe blocks
In Cypress, where should you place
beforeEach hooks to run setup code for all tests inside a nested describe block?Attempts:
2 left
💡 Hint
Think about running setup code before each test in a group.
✗ Incorrect
Placing beforeEach inside the nested describe runs setup before each test in that group only. Outside describe runs for all tests. afterEach runs after tests.