Bird
Raised Fist0
Cypresstesting~20 mins

Percy integration basics in Cypress - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Percy Integration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Percy snapshot command output
What is the output result of running this Cypress test code with Percy integration?
Cypress
describe('Visual test', () => {
  it('takes a Percy snapshot', () => {
    cy.visit('https://example.com')
    cy.percySnapshot('Homepage')
  })
})
ATest passes and a Percy snapshot named 'Homepage' is sent to Percy service
BTest fails with 'cy.percySnapshot is not a function' error
CTest passes but no snapshot is sent to Percy
DTest fails with a timeout error on cy.visit
Attempts:
2 left
💡 Hint
Check if Percy plugin is properly installed and configured in Cypress.
❓ assertion
intermediate
2:00remaining
Correct assertion for Percy snapshot existence
Which assertion correctly verifies that a Percy snapshot was created during a Cypress test run?
Cypress
cy.percySnapshot('Login Page')
// What assertion verifies snapshot creation?
Acy.contains('Snapshot created').should('be.visible')
BNo direct Cypress assertion; snapshot success is verified in Percy dashboard
Ccy.get('.percy-snapshot').should('exist')
Dcy.percySnapshot('Login Page').should('be.called')
Attempts:
2 left
💡 Hint
Percy snapshots are sent to an external service, not visible in the DOM.
🔧 Debug
advanced
2:00remaining
Debugging Percy snapshot failure in Cypress
You run a Cypress test with cy.percySnapshot but no snapshots appear in Percy dashboard. What is the most likely cause?
AThe tested page URL is invalid causing cy.visit to fail
Bcy.percySnapshot command is misspelled as cy.percySnapShot
CPercy token environment variable is missing or incorrect
DThe test does not include any cy.visit command
Attempts:
2 left
💡 Hint
Check environment variables and Percy configuration.
🧠 Conceptual
advanced
2:00remaining
Understanding Percy snapshot timing in Cypress tests
When is the best time to call cy.percySnapshot in a Cypress test to capture the correct visual state?
AAfter all UI elements have loaded and any animations have completed
BBefore cy.visit to capture the previous page state
CImmediately after cy.visit, before any UI changes or waits
DAt the very end of the test, after cy.clearCookies
Attempts:
2 left
💡 Hint
Think about when the page is fully ready visually.
❓ framework
expert
2:00remaining
Configuring Percy with Cypress in CI environment
Which configuration step is essential to ensure Percy snapshots are uploaded during CI runs with Cypress?
AInstall Percy CLI globally on the CI machine only
BDisable all Cypress retries to avoid duplicate snapshots
CRun Cypress tests with --headless flag only
DSet the PERCY_TOKEN environment variable in the CI environment
Attempts:
2 left
💡 Hint
Think about authentication with Percy service in CI.

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

  1. Step 1: Understand Percy's role in testing

    Percy is used to capture screenshots during tests to detect visual changes.
  2. 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.
  3. Final Answer:

    To catch visual bugs by taking screenshots during tests -> Option B
  4. 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

  1. Step 1: Recall Percy snapshot command syntax

    The correct command is cy.percySnapshot('name') to capture snapshots.
  2. Step 2: Match options with correct syntax

    Only cy.percySnapshot('Homepage') matches the exact syntax cy.percySnapshot('Homepage').
  3. Final Answer:

    cy.percySnapshot('Homepage') -> Option C
  4. 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:
describe('Visual test', () => {
  it('checks homepage', () => {
    cy.visit('/')
    cy.percySnapshot('Homepage loaded')
    cy.get('#login').click()
    cy.percySnapshot('Login clicked')
  })
})

How many Percy snapshots will be captured during this test run?
medium
A. 1
B. 3
C. 0
D. 2

Solution

  1. Step 1: Count cy.percySnapshot calls in the test

    There are two calls: one after visiting homepage, one after clicking login.
  2. Step 2: Confirm each call triggers a snapshot

    Each cy.percySnapshot() call captures one snapshot, so total is 2.
  3. Final Answer:

    2 -> Option D
  4. Quick Check:

    Number of snapshots = 2 [OK]
Hint: Count cy.percySnapshot() calls in test [OK]
Common Mistakes:
  • Counting only one snapshot
  • Assuming snapshots auto-capture without calls
  • Confusing clicks with snapshots
4. You wrote this Cypress test with Percy snapshot:
it('checks page', () => {
  cy.visit('/page')
  cy.percySnapshot()
})

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

  1. Step 1: Check cy.percySnapshot usage

    The cy.percySnapshot() command requires a name string argument to identify the snapshot.
  2. Step 2: Identify missing argument issue

    Since no name is given, Percy does not capture or upload the snapshot.
  3. Final Answer:

    Missing snapshot name argument in cy.percySnapshot() -> Option A
  4. 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

  1. Step 1: Identify required Percy snapshots

    Snapshots needed at three steps: before filling, after filling, after submission.
  2. 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.
  3. Final Answer:

    Code snippet with three named Percy snapshots at correct steps -> Option A
  4. 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 unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard