Percy is a visual testing tool that integrates with Cypress to capture screenshots and compare them over time to detect visual changes in your web application.
Click to reveal answer
beginner
How do you install Percy in a Cypress project?
You install Percy by running <code>npm install --save-dev @percy/cypress</code> and then adding <code>import '@percy/cypress'</code> in your Cypress support file.
Click to reveal answer
beginner
What command do you use to start a Percy visual test in a Cypress test?
You use cy.percySnapshot('snapshot name') inside your Cypress test to take a visual snapshot for Percy to compare.
Click to reveal answer
beginner
Why is it important to give descriptive names to Percy snapshots?
Descriptive names help you easily identify which page or component the snapshot represents when reviewing visual changes in the Percy dashboard.
Click to reveal answer
intermediate
What environment variable must be set to authenticate Percy in CI?
You must set the PERCY_TOKEN environment variable with your Percy project token to authenticate and upload snapshots during Continuous Integration.
Click to reveal answer
Which command installs Percy for Cypress?
Anpm install --save-dev @percy/cypress
Bnpm install --save-dev cypress-percy
Cnpm install percy-cypress
Dnpm install --save-dev @cypress/percy
✗ Incorrect
The correct package name is '@percy/cypress' installed with npm using --save-dev.
How do you take a visual snapshot in a Cypress test using Percy?
Apercy.snapshot('name')
Bcy.snapshot('name')
Ccy.percySnapshot('name')
Dcy.takeSnapshot('name')
✗ Incorrect
The correct command is cy.percySnapshot('name') to capture a Percy snapshot.
Where should you import '@percy/cypress' in your Cypress project?
AIn the test file
BIn the Cypress support file
CIn the Cypress plugins file
DIn the package.json
✗ Incorrect
You import '@percy/cypress' in the Cypress support file to make Percy commands available globally.
What does Percy compare to detect visual changes?
AHTML code differences
BJavaScript errors
CCSS stylesheets
DScreenshots over time
✗ Incorrect
Percy compares screenshots taken at different times to find visual differences.
What must be set in CI to upload Percy snapshots?
APERCY_TOKEN
BCYPRESS_TOKEN
CPERFORMANCE_TOKEN
DPERCY_API_KEY
✗ Incorrect
The environment variable PERCY_TOKEN must be set with your Percy project token.
Explain how to integrate Percy with Cypress for visual testing.
Think about installation, setup, usage, and authentication.
You got /4 concepts.
Describe why visual testing with Percy is useful in Cypress tests.
Consider the benefits of catching visual differences early.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of integrating Percy with Cypress tests?
easy
A. To speed up test execution time
B. To catch visual bugs by taking screenshots during tests
C. To generate test data automatically
D. To write unit tests for backend APIs
Solution
Step 1: Understand Percy's role in testing
Percy is used to capture screenshots during tests to detect visual changes.
Step 2: Compare options with Percy's purpose
Only To catch visual bugs by taking screenshots during tests matches Percy's function of catching visual bugs via screenshots.
Final Answer:
To catch visual bugs by taking screenshots during tests -> Option B
Quick Check:
Percy purpose = Visual bug detection [OK]
Hint: Percy = visual snapshots during tests [OK]
Common Mistakes:
Thinking Percy speeds up tests
Confusing Percy with test data tools
Assuming Percy writes backend tests
2. Which of the following is the correct syntax to take a Percy snapshot in a Cypress test?
easy
A. percy.cySnapshot('Homepage')
B. cy.snapshotPercy('Homepage')
C. cy.percySnapshot('Homepage')
D. cy.takePercySnapshot('Homepage')
Solution
Step 1: Recall Percy snapshot command syntax
The correct command is cy.percySnapshot('name') to capture snapshots.
Step 2: Match options with correct syntax
Only cy.percySnapshot('Homepage') matches the exact syntax cy.percySnapshot('Homepage').
Final Answer:
cy.percySnapshot('Homepage') -> Option C
Quick Check:
Correct Percy command = cy.percySnapshot() [OK]
Hint: Look for exact cy.percySnapshot() syntax [OK]
Common Mistakes:
Swapping method and object order
Adding extra words like 'take'
Using wrong method names
3. Given this Cypress test snippet with Percy integration:
But Percy dashboard shows no snapshots. What is the likely problem?
medium
A. Missing snapshot name argument in cy.percySnapshot()
B. cy.visit() must be called after cy.percySnapshot()
C. Percy snapshots only work on mobile viewport
D. You must call cy.percySnapshot() twice per test
Solution
Step 1: Check cy.percySnapshot usage
The cy.percySnapshot() command requires a name string argument to identify the snapshot.
Step 2: Identify missing argument issue
Since no name is given, Percy does not capture or upload the snapshot.
Final Answer:
Missing snapshot name argument in cy.percySnapshot() -> Option A
Quick Check:
Snapshot name required = true [OK]
Hint: Always provide a name string to cy.percySnapshot() [OK]
Common Mistakes:
Thinking visit order matters
Believing Percy only works on mobile
Assuming multiple snapshots are mandatory
5. You want to test a form with Percy snapshots at three steps: before filling, after filling, and after submission. Which code snippet correctly integrates Percy snapshots in Cypress?
hard
A. cy.visit('/form')
cy.percySnapshot('Before filling')
cy.get('#input').type('data')
cy.percySnapshot('After filling')
cy.get('#submit').click()
cy.percySnapshot('After submission')
B. cy.visit('/form')
cy.percySnapshot()
cy.get('#input').type('data')
cy.percySnapshot()
cy.get('#submit').click()
cy.percySnapshot()
C. cy.visit('/form')
cy.get('#input').type('data')
cy.percySnapshot('After filling')
cy.get('#submit').click()
D. cy.visit('/form')
cy.get('#submit').click()
cy.percySnapshot('After submission')
Solution
Step 1: Identify required Percy snapshots
Snapshots needed at three steps: before filling, after filling, after submission.
Step 2: Check which snippet has all three snapshots with names
Only cy.visit('/form')
cy.percySnapshot('Before filling')
cy.get('#input').type('data')
cy.percySnapshot('After filling')
cy.get('#submit').click()
cy.percySnapshot('After submission') has three named cy.percySnapshot() calls at correct steps.
Final Answer:
Code snippet with three named Percy snapshots at correct steps -> Option A
Quick Check:
Three named snapshots = cy.visit('/form')
cy.percySnapshot('Before filling')
cy.get('#input').type('data')
cy.percySnapshot('After filling')
cy.get('#submit').click()
cy.percySnapshot('After submission') [OK]
Hint: Name each snapshot and place at correct test steps [OK]
Common Mistakes:
Omitting snapshot names
Missing snapshots at required steps
Calling snapshots before visit
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.