Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cypress to the public app #3

Merged
merged 2 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/public/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# DAHLIA Public Web Interface

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

## What does this do?

- Shows listings

## Getting Started

* `yarn install`
* `yarn dev`

## Running end-to-end tests locally
* Start the Next.js server: `yarn test`
* 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')
3 changes: 3 additions & 0 deletions apps/public/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"dev": "next",
"build": "next build",
"test": "concurrently \"yarn dev\" \"cypress open\"",
"export": "next export",
"start": "next start"
},
Expand All @@ -24,6 +25,8 @@
"devDependencies": {
"@types/node": "^12.6.8",
"@types/react": "^16.8.23",
"concurrently": "^4.1.1",
"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