-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from ASVGay/chore/set-up-cypress
Set up Cypress
- Loading branch information
Showing
9 changed files
with
2,906 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,3 +135,4 @@ fabric.properties | |
**/public/sw.js.map | ||
**/public/worker-*.js | ||
**/public/worker-*.js.map | ||
serviceAccount.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require('dotenv').config() | ||
import admin from 'firebase-admin'; | ||
import { defineConfig } from 'cypress'; | ||
import { plugin as cypressFirebasePlugin } from 'cypress-firebase'; | ||
import PluginConfigOptions = Cypress.PluginConfigOptions; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3000', | ||
// NOTE: Add "supportFile" setting if separate location is used | ||
setupNodeEvents(on, config) { | ||
config.env = { | ||
...process.env, | ||
...config.env | ||
} | ||
// e2e testing node events setup code | ||
return cypressFirebasePlugin(on, config, admin,{ | ||
// Here is where you can pass special options. | ||
// If you have not set the GCLOUD_PROJECT environment variable, give the projectId here, like so: | ||
// projectId: 'some-project', | ||
// if your databaseURL is not just your projectId plus ".firebaseio.com", then you _must_ give it here, like so: | ||
// databaseURL: 'some-project-default-rtdb.europe-west1.firebasedatabase.app', | ||
}) as PluginConfigOptions; | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe('Home Page', () => { | ||
context('Auth redirect situations', () => { | ||
it('should redirect to sign in if logged out', () => { | ||
cy.logout() | ||
cy.visit('/') | ||
cy.location('pathname').should('equal', '/signin') | ||
}) | ||
|
||
it('should stay on the home page if logged in', () => { | ||
cy.login() | ||
cy.visit('/') | ||
cy.location('pathname').should('equal', '/') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference types="cypress" /> | ||
// *********************************************** | ||
// This example commands.ts shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add('login', (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This will overwrite an existing command -- | ||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
// | ||
// declare global { | ||
// namespace Cypress { | ||
// interface Chainable { | ||
// login(email: string, password: string): Chainable<void> | ||
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
|
||
import firebase from 'firebase/compat/app'; | ||
import 'firebase/compat/auth'; | ||
import 'firebase/compat/database'; | ||
import 'firebase/compat/firestore'; | ||
import { attachCustomCommands } from 'cypress-firebase'; | ||
|
||
const firebaseConfig = { | ||
apiKey: Cypress.env('NEXT_PUBLIC_FIREBASE_API_KEY'), | ||
authDomain: Cypress.env('NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN'), | ||
projectId: Cypress.env('NEXT_PUBLIC_FIREBASE_PROJECT_ID'), | ||
storageBucket: Cypress.env('NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET'), | ||
messagingSenderId: Cypress.env('NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID'), | ||
appId: Cypress.env('NEXT_PUBLIC_FIREBASE_APP_ID'), | ||
measurementId: Cypress.env('NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID'), | ||
}; | ||
|
||
firebase.initializeApp(firebaseConfig); | ||
|
||
attachCustomCommands({ Cypress, cy, firebase }); |
Oops, something went wrong.