Skip to content

Instantly share code, notes, and snippets.

@prescottprue
Last active December 1, 2018 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prescottprue/6958e0c3fb12e5e7d898cb695288aa1c to your computer and use it in GitHub Desktop.
Save prescottprue/6958e0c3fb12e5e7d898cb695288aa1c to your computer and use it in GitHub Desktop.
Cypress test for verifying app writes valid data to database
const USER_PROFILE_PATH = `users/${Cypress.env('TEST_UID')}`
describe('Account Page', () => {
beforeEach(() => {
// Login using custom token
cy.login()
// Go to account page
cy.visit('/account')
})
afterEach(() => {
// Reset the displayName in the user's profile to "Test User"
cy.callRtdb('update', USER_PROFILE_PATH, { displayName: 'Test User' })
})
it('User can update their account', () => {
const newDisplayName = 'New Name'
cy.get('[data-test=displayName]').type(newDisplayName)
// Click to create new transaction
cy.get('[data-test=save-account]')).click()
// Get user profile data for value comparison
cy.callRtdb('get', USER_PROFILE_PATH)
.then((account) => {
// Confirm profile contains updated displayName
cy.wrap(account)
.its('displayName')
.should('equal', newDisplayName)
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment