Skip to content

Commit

Permalink
Install Cypress and add a basic example test
Browse files Browse the repository at this point in the history
  • Loading branch information
callaghanc committed Jul 25, 2019
1 parent db03f31 commit 78f6620
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 19 deletions.
8 changes: 8 additions & 0 deletions apps/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Public App v0

This is the beginning of the public-facing DAHLIA app.

## Running end-to-end tests locally
* Start the Next.js server: `yarn dev`
* In a separate terminal, open the Cypress app: `yarn run cypress open`
* In the Cypress app, click on the test called "our_first_test.spec.js". This will open the Cypress test runner in a Chrome browser and run the test.
1 change: 1 addition & 0 deletions apps/public/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions apps/public/cypress/fixtures/example.json
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"
}
14 changes: 14 additions & 0 deletions apps/public/cypress/integration/our_first_test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe('Our First Test', function() {
it("Loads the public app's homepage", function() {
cy.visit('http://localhost:3000')

// Check that the "Hello World" text is present on the page
cy.contains('Hello World')

// Find the About page link and click it
cy.contains('About').click()

// Should be on a new URL which includes '/about'
cy.url().should('include', '/about')
})
})
17 changes: 17 additions & 0 deletions apps/public/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
25 changes: 25 additions & 0 deletions apps/public/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js 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 is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions apps/public/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js 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')
1 change: 1 addition & 0 deletions apps/public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"devDependencies": {
"@types/node": "^12.6.8",
"@types/react": "^16.8.23",
"cypress": "^3.4.0",
"next-transpile-modules": "^2.3.1",
"typescript": "^3.5.3",
"webpack": "4.37.0"
Expand Down
6 changes: 6 additions & 0 deletions apps/public/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default () => (
<>
<h1>About</h1>
<p>This is the about page.</p>
</>
);
Loading

0 comments on commit 78f6620

Please sign in to comment.