Skip to content

Commit 9195e16

Browse files
committed
Add Cypress e2e tests
1 parent d306d17 commit 9195e16

File tree

10 files changed

+1088
-18
lines changed

10 files changed

+1088
-18
lines changed

.circleci/config.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
version: 2.1
22

33
jobs:
4-
run_tests:
4+
run_e2e_tests:
5+
docker:
6+
- image: cypress/browsers:node10.16.0-chrome77
7+
environment:
8+
TERM: xterm
9+
steps:
10+
- checkout
11+
- run:
12+
command: npm install
13+
- run:
14+
command: cd example && npm install
15+
- run:
16+
command: cd example && npm start
17+
background: true
18+
- run:
19+
command: npx wait-on -d 60000 http://localhost:3000
20+
- run:
21+
command: npm run ci:cypress
22+
23+
run_integration_and_unit_tests:
524
docker:
625
- image: circleci/node:10.18.1
726
environment:
@@ -16,4 +35,5 @@ jobs:
1635
workflows:
1736
tests:
1837
jobs:
19-
- run_tests
38+
- run_integration_and_unit_tests
39+
- run_e2e_tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ yarn-error.log*
2222

2323
# coverage report
2424
coverage
25+
26+
# cypress
27+
cypress/examples
28+
cypress/videos

cypress.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"baseUrl": "http://localhost:3000",
3+
"pageLoadTimeout": 180000,
4+
"projectId": "fsyzwo",
5+
"chromeWebSecurity": false
6+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/integration/marker.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe("react-hook-google-maps", () => {
2+
before(() => {
3+
cy.visit("/");
4+
});
5+
it("renders Google Maps one with a marker", () => {
6+
cy.findAllByText("This page can't load Google Maps correctly.").should(
7+
"have.length",
8+
2,
9+
);
10+
cy.findAllByText("OK").click({ multiple: true });
11+
cy.queryAllByText("This page can't load Google Maps correctly.").should(
12+
"not.exist",
13+
);
14+
// map marker can be selected with document.querySelectorAll("img[usemap='#gmimap0']");
15+
cy.get("img[usemap='#gmimap0']").should("have.length", 1);
16+
});
17+
});

cypress/plugins/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// ***********************************************************
2+
// This example plugins/index.js can be used to load plugins
3+
//
4+
// You can change the location of this file or turn off loading
5+
// the plugins file with the 'pluginsFile' configuration option.
6+
//
7+
// You can read more here:
8+
// https://on.cypress.io/plugins-guide
9+
// ***********************************************************
10+
11+
// This function is called when a project is opened or re-opened (e.g. due to
12+
// the project's config changing)
13+
14+
module.exports = (on, config) => {
15+
// `on` is used to hook into various events Cypress emits
16+
// `config` is the resolved Cypress config
17+
}

cypress/support/commands.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ***********************************************
2+
// This example commands.js shows you how to
3+
// create various custom commands and overwrite
4+
// existing commands.
5+
//
6+
// For more comprehensive examples of custom
7+
// commands please read more here:
8+
// https://on.cypress.io/custom-commands
9+
// ***********************************************
10+
//
11+
//
12+
// -- This is a parent command --
13+
// Cypress.Commands.add("login", (email, password) => { ... })
14+
//
15+
//
16+
// -- This is a child command --
17+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
18+
//
19+
//
20+
// -- This is a dual command --
21+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
22+
//
23+
//
24+
// -- This is will overwrite an existing command --
25+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
26+
27+
// install cypress-testing-library
28+
import '@testing-library/cypress/add-commands';

cypress/support/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/index.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

0 commit comments

Comments
 (0)