Skip to content

Instantly share code, notes, and snippets.

@prescottprue
Last active November 24, 2018 03:44
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/58f98d5b08d0a8ed97192ee9b0de00cb to your computer and use it in GitHub Desktop.
Save prescottprue/58f98d5b08d0a8ed97192ee9b0de00cb to your computer and use it in GitHub Desktop.
Cypress test to confirm a Firebase app correctly routes authed/unauthed users.
describe('Projects Page', () => {
describe('when not authenticated', () => {
before(() => {
// Attempt to go to /projects (requires user to be logged in)
cy.visit('/projects')
})
it('Redirects to Home (/)', () => {
cy.url().should('equal', '/')
});
})
describe('when authenticated', () => {
before(() => {
// Login using custom token
cy.login()
// Go to /projects (which requires user to be logged in)
cy.visit('/projects')
})
it('Does not redirect', () => {
cy.url().should('equal', '/projects')
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment