Skip to content

Commit

Permalink
✨ add Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Aug 10, 2020
1 parent 53e32ae commit ead8bc1
Show file tree
Hide file tree
Showing 15 changed files with 1,129 additions and 24 deletions.
3 changes: 3 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:3000"
}
Binary file added cypress/.DS_Store
Binary file not shown.
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"
}
8 changes: 8 additions & 0 deletions cypress/integration/first-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* globals cy */

describe('Homepage', () => {
it('should perform basic google search', () => {
cy.visit('/');
cy.get('#count').should('have.length', 1);
});
});
17 changes: 17 additions & 0 deletions 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 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')
Binary file added cypress/videos/home.js.mp4
Binary file not shown.
Binary file added cypress/videos/promotions.js.mp4
Binary file not shown.
Binary file added cypress/videos/search.js.mp4
Binary file not shown.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"author": "Antistatique",
"license": "MIT",
"scripts": {
"lint:js": "eslint --ext js,jsx,ts,tsx ./ --max-warnings=0"
"lint:js": "eslint --ext js,jsx,ts,tsx ./ --max-warnings=0",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.2",
Expand All @@ -16,6 +18,7 @@
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"babel-eslint": "^10.1.0",
"cypress": "^4.12.1",
"eslint": "^7.2.0",
"eslint-config-airbnb-typescript": "^9.0.0",
"eslint-config-prettier": "^6.11.0",
Expand Down
4 changes: 3 additions & 1 deletion playground/src/components/Counter/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const Counter = (): JSX.Element => {
>
-
</button>
<span tw="px-4 font-bold text-2xl">{count}</span>
<span id="count" tw="px-4 font-bold text-2xl">
{count}
</span>
<button
type="button"
onClick={() => setCount(i => i + 1)}
Expand Down
3 changes: 2 additions & 1 deletion playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext"
"target": "esnext",
"types": ["cypress"],
},
"exclude": ["node_modules"],
"files": ["./src/types/twin.d.ts"],
Expand Down
31 changes: 31 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"allowJs": true,
"alwaysStrict": true,
"baseUrl": "src",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["dom", "es2017"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"types": ["cypress"],
},
"exclude": ["node_modules"],
"files": ["./src/types/twin.d.ts"],
"include": [
"./**/*.ts",
"./**/*.tsx",
"./**/*.js",
"./**/*.jsx"
]
}

0 comments on commit ead8bc1

Please sign in to comment.