Skip to content

Commit

Permalink
feat: add cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
phatnguyenuit committed Jan 23, 2021
1 parent 531f849 commit 11778e1
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"plugins": ["prettier"],
"plugins": ["prettier", "cypress"],
"extends": [
"react-app",
"react-app/jest",
"prettier/@typescript-eslint",
"plugin:cypress/recommended",
"plugin:prettier/recommended"
],
"rules": {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ yarn-debug.log*
yarn-error.log*
yarn.lock
.eslintcache

# Custom
cypress/integration/examples
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
- [x] Upload to Cov
- [x] Setup Sentry
- [x] Sentry Error boundary
- [ ] End to end test with Cypress
- [x] End to end test with Cypress
- [ ] Write awesome README
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions cypress/cypress-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="cypress" />
5 changes: 5 additions & 0 deletions 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": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
9 changes: 9 additions & 0 deletions cypress/integration/meta-weather/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('dashboard', () => {
beforeEach(() => {
cy.visit('http://localhost:4001');
});

it('should render dashboard', () => {
cy.url().should('include', '/weathers');
});
});
21 changes: 21 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference types="cypress" />
// ***********************************************************
// 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)

/**
* @type {Cypress.PluginConfig}
*/
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 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 will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions 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')
10 changes: 10 additions & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"isolatedModules": false,
"types": ["cypress"]
},
"include": [
"integration"
]
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"release": "release-it",
"type-check": "tsc --noEmit",
"predeploy": "yarn build",
"deploy": "gh-pages -d build"
"deploy": "gh-pages -d build",
"cy:open": "cypress open"
},
"eslintConfig": {
"extends": "react-app"
Expand Down Expand Up @@ -69,8 +70,10 @@
"@types/react-redux": "^7.1.15",
"@types/react-router-dom": "^5.1.7",
"commitizen": "^4.2.2",
"cypress": "^6.3.0",
"cz-conventional-changelog": "3.3.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-prettier": "^3.2.0",
"gh-pages": "^3.1.0",
"husky": "^4.3.8",
Expand Down

0 comments on commit 11778e1

Please sign in to comment.