0
0
Cypresstesting~10 mins

Why external test data improves maintainability in Cypress - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load external test data using Cypress.

Cypress
cy.fixture('[1]').then((data) => { cy.log(data.username); });
Drag options to blanks, or click blank then click option'
AtestData.json
Bdata.js
Cconfig.yaml
Dinput.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-JSON file like .txt or .yaml with cy.fixture causes errors.
Forgetting to include the file extension in the fixture name.
2fill in blank
medium

Complete the code to use external test data for filling a login form.

Cypress
cy.fixture('users.json').then((users) => { cy.get('#username').type(users.[1]); });
Drag options to blanks, or click blank then click option'
Apassword
Busername
Cemail
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'password' or 'email' when the input expects username.
Using keys that do not exist in the fixture data.
3fill in blank
hard

Fix the error in the code to correctly assert the loaded test data.

Cypress
cy.fixture('data.json').then((data) => { expect(data.[1]).to.equal('admin'); });
Drag options to blanks, or click blank then click option'
Auser
Bpassword
Cusername
Drole
Attempts:
3 left
💡 Hint
Common Mistakes
Using keys like 'user' or 'role' that do not match the expected value.
Typos in the key name causing undefined values.
4fill in blank
hard

Fill both blanks to create a reusable test that uses external data for login and asserts the welcome message.

Cypress
cy.fixture('[1]').then((user) => { cy.get('#username').type(user.username); cy.get('#password').type(user.[2]); cy.get('#loginBtn').click(); cy.contains('Welcome').should('be.visible'); });
Drag options to blanks, or click blank then click option'
AloginData.json
Bpassword
Cemail
DuserData.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect fixture file names like 'userData.json' when the file is 'loginData.json'.
Using 'email' instead of 'password' for the password input.
5fill in blank
hard

Fill all three blanks to load external test data, perform login, and verify the user role on the dashboard.

Cypress
cy.fixture('[1]').then((user) => { cy.get('#username').type(user.[2]); cy.get('#password').type(user.password); cy.get('#loginBtn').click(); cy.get('.role').should('contain.text', user.[3]); });
Drag options to blanks, or click blank then click option'
Ausers.json
Busername
Crole
Dlogin.json
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong fixture file names like 'login.json'.
Using incorrect keys like 'email' or 'id' instead of 'username' or 'role'.