From 53cca9ad40b1980e2019adfbcfe2341a3fb07c7b Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 13:06:27 +0900 Subject: [PATCH 01/21] Integrate cypress --- .github/workflows/ci.yml | 25 +++++++++ .husky/pre-push | 0 cypress.config.ts | 12 +++++ cypress/fixtures/example.json | 5 ++ cypress/integration/sample.spec.ts | 17 ++++++ cypress/support/commands.ts | 37 +++++++++++++ cypress/support/e2e.ts | 20 +++++++ package-lock.json | 84 +++++++----------------------- package.json | 8 +-- src/App.test.tsx | 9 ---- src/App.tsx | 36 +++++-------- 11 files changed, 153 insertions(+), 100 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .husky/pre-push create mode 100644 cypress.config.ts create mode 100644 cypress/fixtures/example.json create mode 100644 cypress/integration/sample.spec.ts create mode 100644 cypress/support/commands.ts create mode 100644 cypress/support/e2e.ts delete mode 100644 src/App.test.tsx diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0450458 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: npm install + + - name: Run Cypress tests + run: npm run cypress:run diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 0000000..e69de29 diff --git a/cypress.config.ts b/cypress.config.ts new file mode 100644 index 0000000..038ab3c --- /dev/null +++ b/cypress.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'cypress'; + +export default defineConfig({ + projectId: '8wqgav', + e2e: { + setupNodeEvents(on, config) { + // implement node event listeners here + }, + specPattern: 'cypress/integration/**/*.spec.{js,jsx,ts,tsx}', + baseUrl: 'http://localhost:3000', + }, +}); diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 0000000..02e4254 --- /dev/null +++ b/cypress/fixtures/example.json @@ -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" +} diff --git a/cypress/integration/sample.spec.ts b/cypress/integration/sample.spec.ts new file mode 100644 index 0000000..daef87a --- /dev/null +++ b/cypress/integration/sample.spec.ts @@ -0,0 +1,17 @@ +describe('Counter App', () => { + beforeEach(() => { + cy.visit('/'); + }); + + it('increments the counter', () => { + cy.get('p[data-testid="count"]').should('have.text', '0'); + cy.get('button').contains('Increment').click(); + cy.get('p[data-testid="count"]').should('have.text', '1'); + }); + + it('decrements the counter', () => { + cy.get('p[data-testid="count"]').should('have.text', '0'); + cy.get('button').contains('Decrement').click(); + cy.get('p[data-testid="count"]').should('have.text', '-1'); + }); +}); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts new file mode 100644 index 0000000..698b01a --- /dev/null +++ b/cypress/support/commands.ts @@ -0,0 +1,37 @@ +/// +// *********************************************** +// This example commands.ts 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) => { ... }) +// +// declare global { +// namespace Cypress { +// interface Chainable { +// login(email: string, password: string): Chainable +// drag(subject: string, options?: Partial): Chainable +// dismiss(subject: string, options?: Partial): Chainable +// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable +// } +// } +// } \ No newline at end of file diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts new file mode 100644 index 0000000..f80f74f --- /dev/null +++ b/cypress/support/e2e.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/e2e.ts 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') \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ed3af91..0eb6280 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,8 +20,8 @@ "web-vitals": "^2.1.4" }, "devDependencies": { - "@playwright/test": "^1.44.1", - "cypress": "^13.11.0" + "cypress": "^13.12.0", + "husky": "^9.0.11" } }, "node_modules/@alloc/quick-lru": { @@ -3343,21 +3343,6 @@ "node": ">=14" } }, - "node_modules/@playwright/test": { - "version": "1.44.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.44.1.tgz", - "integrity": "sha512-1hZ4TNvD5z9VuhNJ/walIjvMVvYkZKf71axoF/uiAqpntQJXpG64dlXhoDXE3OczPuTuvjf/M5KWFg5VAVUS3Q==", - "dev": true, - "dependencies": { - "playwright": "1.44.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=16" - } - }, "node_modules/@pmmmwh/react-refresh-webpack-plugin": { "version": "0.5.15", "resolved": "https://registry.npmjs.org/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.15.tgz", @@ -6631,9 +6616,9 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, "node_modules/cypress": { - "version": "13.11.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.11.0.tgz", - "integrity": "sha512-NXXogbAxVlVje4XHX+Cx5eMFZv4Dho/2rIcdBHg9CNPFUGZdM4cRdgIgM7USmNYsC12XY0bZENEQ+KBk72fl+A==", + "version": "13.12.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-13.12.0.tgz", + "integrity": "sha512-udzS2JilmI9ApO/UuqurEwOvThclin5ntz7K0BtnHBs+tg2Bl9QShLISXpSEMDv/u8b6mqdoAdyKeZiSqKWL8g==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -9654,6 +9639,21 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "9.0.11", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.0.11.tgz", + "integrity": "sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw==", + "dev": true, + "bin": { + "husky": "bin.mjs" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -13883,50 +13883,6 @@ "node": ">=4" } }, - "node_modules/playwright": { - "version": "1.44.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.44.1.tgz", - "integrity": "sha512-qr/0UJ5CFAtloI3avF95Y0L1xQo6r3LQArLIg/z/PoGJ6xa+EwzrwO5lpNr/09STxdHuUoP2mvuELJS+hLdtgg==", - "dev": true, - "dependencies": { - "playwright-core": "1.44.1" - }, - "bin": { - "playwright": "cli.js" - }, - "engines": { - "node": ">=16" - }, - "optionalDependencies": { - "fsevents": "2.3.2" - } - }, - "node_modules/playwright-core": { - "version": "1.44.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.44.1.tgz", - "integrity": "sha512-wh0JWtYTrhv1+OSsLPgFzGzt67Y7BE/ZS3jEqgGBlp2ppp1ZDj8c+9IARNW4dwf1poq5MgHreEM2KV/GuR4cFA==", - "dev": true, - "bin": { - "playwright-core": "cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/playwright/node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", diff --git a/package.json b/package.json index ccbfa53..af69833 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,8 @@ "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", - "jest": "npm run test:jest", - "cypress": "npm run cypress", - "playwright": "npx playwright test" + "cypress:open": "cypress open", + "cypress:run": "cypress run" }, "eslintConfig": { "extends": [ @@ -42,6 +41,7 @@ ] }, "devDependencies": { - "cypress": "^13.11.0" + "cypress": "^13.12.0", + "husky": "^9.0.11" } } diff --git a/src/App.test.tsx b/src/App.test.tsx deleted file mode 100644 index 2a68616..0000000 --- a/src/App.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/src/App.tsx b/src/App.tsx index a53698a..2652328 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,26 +1,16 @@ -import React from 'react'; -import logo from './logo.svg'; -import './App.css'; +import React, { useState } from 'react'; -function App() { - return ( -
-
- logo -

- Edit src/App.tsx and save to reload. -

- - Learn React - -
-
- ); -} +const App: React.FC = () => { + const [count, setCount] = useState(0); + + return ( +
+

Counter

+

{count}

+ + +
+ ); +}; export default App; From 22b838bda081e006f8c87e01dc7264431aac38d6 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 13:22:13 +0900 Subject: [PATCH 02/21] Install start-server-and-test --- .github/workflows/ci.yml | 5 ++++- package.json | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0450458..574cb1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,5 +21,8 @@ jobs: - name: Install dependencies run: npm install + - name: Start React app + run: npm start + - name: Run Cypress tests - run: npm run cypress:run + run: npm run test diff --git a/package.json b/package.json index af69833..ffe505c 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ "scripts": { "start": "react-scripts start", "build": "react-scripts build", - "test": "react-scripts test", "eject": "react-scripts eject", - "cypress:open": "cypress open", - "cypress:run": "cypress run" + "cy:open": "cypress open", + "cy:run": "cypress run", + "test": "start-server-and-test start http://localhost:3030 cy:run" }, "eslintConfig": { "extends": [ From b15306e326eff4c265792123871082ce13b534f4 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 13:29:45 +0900 Subject: [PATCH 03/21] Update ci.yml --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 574cb1f..c23d217 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,5 @@ jobs: - name: Install dependencies run: npm install - - name: Start React app - run: npm start - - name: Run Cypress tests run: npm run test From 784802647a83fdebedda53f4d6cc5d6565cac9b6 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 13:33:27 +0900 Subject: [PATCH 04/21] Install start-server-and-test --- package-lock.json | 198 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 5 +- 2 files changed, 200 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0eb6280..b641eef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,8 @@ }, "devDependencies": { "cypress": "^13.12.0", - "husky": "^9.0.11" + "husky": "^9.0.11", + "start-server-and-test": "^2.0.4" } }, "node_modules/@alloc/quick-lru": { @@ -2481,6 +2482,21 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==", + "dev": true + }, + "node_modules/@hapi/topo": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@hapi/topo/-/topo-5.1.0.tgz", + "integrity": "sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -3469,6 +3485,27 @@ "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.10.3.tgz", "integrity": "sha512-qC/xYId4NMebE6w/V33Fh9gWxLgURiNYgVNObbJl2LZv0GUUItCcCqC5axQSwRaAgaxl2mELq1rMzlswaQ0Zxg==" }, + "node_modules/@sideway/address": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", + "integrity": "sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.0.0" + } + }, + "node_modules/@sideway/formula": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sideway/formula/-/formula-3.0.1.tgz", + "integrity": "sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==", + "dev": true + }, + "node_modules/@sideway/pinpoint": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@sideway/pinpoint/-/pinpoint-2.0.0.tgz", + "integrity": "sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==", + "dev": true + }, "node_modules/@sinclair/typebox": { "version": "0.24.51", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz", @@ -5163,6 +5200,37 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/axios/node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -8256,6 +8324,21 @@ "node": ">= 0.6" } }, + "node_modules/event-stream": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==", + "dev": true, + "dependencies": { + "duplexer": "~0.1.1", + "from": "~0", + "map-stream": "~0.1.0", + "pause-stream": "0.0.11", + "split": "0.3", + "stream-combiner": "~0.0.4", + "through": "~2.3.1" + } + }, "node_modules/eventemitter2": { "version": "6.4.7", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.7.tgz", @@ -8955,6 +9038,12 @@ "node": ">= 0.6" } }, + "node_modules/from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", + "dev": true + }, "node_modules/fs-extra": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", @@ -12427,6 +12516,19 @@ "jiti": "bin/jiti.js" } }, + "node_modules/joi": { + "version": "17.13.3", + "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.3.tgz", + "integrity": "sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==", + "dev": true, + "dependencies": { + "@hapi/hoek": "^9.3.0", + "@hapi/topo": "^5.1.0", + "@sideway/address": "^4.1.5", + "@sideway/formula": "^3.0.1", + "@sideway/pinpoint": "^2.0.0" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -13054,6 +13156,12 @@ "tmpl": "1.0.5" } }, + "node_modules/map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", + "dev": true + }, "node_modules/mdn-data": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz", @@ -13776,6 +13884,15 @@ "node": ">=8" } }, + "node_modules/pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==", + "dev": true, + "dependencies": { + "through": "~2.3" + } + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", @@ -15217,6 +15334,21 @@ "integrity": "sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A==", "dev": true }, + "node_modules/ps-tree": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.2.0.tgz", + "integrity": "sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==", + "dev": true, + "dependencies": { + "event-stream": "=3.3.4" + }, + "bin": { + "ps-tree": "bin/ps-tree.js" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -16685,6 +16817,18 @@ "wbuf": "^1.7.3" } }, + "node_modules/split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==", + "dev": true, + "dependencies": { + "through": "2" + }, + "engines": { + "node": "*" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -16745,6 +16889,30 @@ "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==" }, + "node_modules/start-server-and-test": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/start-server-and-test/-/start-server-and-test-2.0.4.tgz", + "integrity": "sha512-CKNeBTcP0hVqIlNismHMudb9q3lLdAjcVPO13/7gfI66fcJpeIb/o4NzQd1JK/CD+lfWVqr10ZH9Y14+OwlJuw==", + "dev": true, + "dependencies": { + "arg": "^5.0.2", + "bluebird": "3.7.2", + "check-more-types": "2.24.0", + "debug": "4.3.5", + "execa": "5.1.1", + "lazy-ass": "1.6.0", + "ps-tree": "1.2.0", + "wait-on": "7.2.0" + }, + "bin": { + "server-test": "src/bin/start.js", + "start-server-and-test": "src/bin/start.js", + "start-test": "src/bin/start.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/static-eval": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", @@ -16846,6 +17014,15 @@ "node": ">= 0.8" } }, + "node_modules/stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==", + "dev": true, + "dependencies": { + "duplexer": "~0.1.1" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -18068,6 +18245,25 @@ "node": ">=10" } }, + "node_modules/wait-on": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-7.2.0.tgz", + "integrity": "sha512-wCQcHkRazgjG5XoAq9jbTMLpNIjoSlZslrJ2+N9MxDsGEv1HnFoVjOCexL0ESva7Y9cu350j+DWADdk54s4AFQ==", + "dev": true, + "dependencies": { + "axios": "^1.6.1", + "joi": "^17.11.0", + "lodash": "^4.17.21", + "minimist": "^1.2.8", + "rxjs": "^7.8.1" + }, + "bin": { + "wait-on": "bin/wait-on" + }, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", diff --git a/package.json b/package.json index ffe505c..bb9c55e 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "eject": "react-scripts eject", "cy:open": "cypress open", "cy:run": "cypress run", - "test": "start-server-and-test start http://localhost:3030 cy:run" + "test": "start-server-and-test start http://localhost:3000 cy:run" }, "eslintConfig": { "extends": [ @@ -42,6 +42,7 @@ }, "devDependencies": { "cypress": "^13.12.0", - "husky": "^9.0.11" + "husky": "^9.0.11", + "start-server-and-test": "^2.0.4" } } From f31275a3bfe601acf23f6b33eb81982f4d145d4c Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 14:58:40 +0900 Subject: [PATCH 05/21] add cypress record key --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c23d217..e00c989 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,6 @@ jobs: run: npm install - name: Run Cypress tests - run: npm run test + run: npx cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --parallel + env: + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} From a745273f5e0eef668da50a9575d321412e29cd5a Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 16:17:01 +0900 Subject: [PATCH 06/21] Update ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e00c989..0004b5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,6 @@ jobs: run: npm install - name: Run Cypress tests - run: npx cypress run --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --parallel + run: npm run test -- --record --key ${{ secrets.CYPRESS_RECORD_KEY }} env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} From 8874db4791248f5458fbc23b20a7976685a1a916 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 16:22:20 +0900 Subject: [PATCH 07/21] Update ci --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0004b5c..f1869ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,6 @@ jobs: run: npm install - name: Run Cypress tests - run: npm run test -- --record --key ${{ secrets.CYPRESS_RECORD_KEY }} + run: npm run test env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} diff --git a/package.json b/package.json index bb9c55e..1eeb587 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "cypress run", + "cy:run": "cypress run --record --key $CYPRESS_RECORD_KEY", "test": "start-server-and-test start http://localhost:3000 cy:run" }, "eslintConfig": { From aaf44a39433c37b705a02fc97969f96addc36b34 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 20 Jun 2024 16:27:22 +0900 Subject: [PATCH 08/21] Update action --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1869ce..186af17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,6 @@ jobs: run: npm install - name: Run Cypress tests - run: npm run test env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + run: npm run test --record --key "$CYPRESS_RECORD_KEY" diff --git a/package.json b/package.json index 1eeb587..bb9c55e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "cypress run --record --key $CYPRESS_RECORD_KEY", + "cy:run": "cypress run", "test": "start-server-and-test start http://localhost:3000 cy:run" }, "eslintConfig": { From da6a8e160ecff9238fc44e1dd46369fffc7fbc26 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Mon, 24 Jun 2024 13:35:31 +0900 Subject: [PATCH 09/21] update --- .env.example | 1 + .gitignore | 1 + package-lock.json | 40 +++++++++++++++++++++++++++++++++++++--- package.json | 5 +++-- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..81773a8 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +CYPRESS_RECORD_KEY= diff --git a/.gitignore b/.gitignore index 4d29575..8692cf6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/package-lock.json b/package-lock.json index b641eef..2a78d4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@types/node": "^16.18.98", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "dotenv-cli": "^7.4.2", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", @@ -7291,11 +7292,36 @@ } }, "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-cli": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-7.4.2.tgz", + "integrity": "sha512-SbUj8l61zIbzyhIbg0FwPJq6+wjbzdn9oEtozQpZ6kW2ihCcapKVZj49oCT3oPM+mgQm+itgvUQcG5szxVrZTA==", + "dependencies": { + "cross-spawn": "^7.0.3", + "dotenv": "^16.3.0", + "dotenv-expand": "^10.0.0", + "minimist": "^1.2.6" + }, + "bin": { + "dotenv": "cli.js" + } + }, + "node_modules/dotenv-cli/node_modules/dotenv-expand": { "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz", + "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==", "engines": { - "node": ">=10" + "node": ">=12" } }, "node_modules/dotenv-expand": { @@ -15784,6 +15810,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index bb9c55e..c18f0c5 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@types/node": "^16.18.98", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "dotenv-cli": "^7.4.2", "react": "^18.3.1", "react-dom": "^18.3.1", "react-scripts": "5.0.1", @@ -19,8 +20,8 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "cypress run", - "test": "start-server-and-test start http://localhost:3000 cy:run" + "cy:run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", + "test": "start-server-and-test start 3000 cy:run" }, "eslintConfig": { "extends": [ From 25df95560a376d8ceaaa02b1055817ccf35e54c1 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Mon, 24 Jun 2024 13:43:19 +0900 Subject: [PATCH 10/21] Add pre-push --- .husky/pre-push | 1 + 1 file changed, 1 insertion(+) diff --git a/.husky/pre-push b/.husky/pre-push index e69de29..e37998f 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -0,0 +1 @@ +npm run test From b78ea6eeb51e9949cdf771d6f48e5618a2de7d3f Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Mon, 24 Jun 2024 13:46:10 +0900 Subject: [PATCH 11/21] prepare husky --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c18f0c5..a8591c5 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "eject": "react-scripts eject", "cy:open": "cypress open", "cy:run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", - "test": "start-server-and-test start 3000 cy:run" + "test": "start-server-and-test start 3000 cy:run", + "prepare": "husky" }, "eslintConfig": { "extends": [ From 231ee3bc47e107f0c913b0cf8dd4c856038274a5 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Mon, 24 Jun 2024 15:49:28 +0900 Subject: [PATCH 12/21] Fix node-version in ci --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 186af17..0f43908 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,12 +11,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '16.20.2' - name: Install dependencies run: npm install From c3715c5a7601e9341d9b0c595f86563ae61624e4 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 27 Jun 2024 09:17:40 +0900 Subject: [PATCH 13/21] update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a8591c5..ff710b4 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", + "cy:run": "cypress run", "test": "start-server-and-test start 3000 cy:run", "prepare": "husky" }, From 5031ce407dcbafb89f98ada3828331ebd721c44b Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 27 Jun 2024 09:21:04 +0900 Subject: [PATCH 14/21] update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ff710b4..a8591c5 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "cypress run", + "cy:run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", "test": "start-server-and-test start 3000 cy:run", "prepare": "husky" }, From 257ce19009396829a4cd0bb632f13c980f3115cf Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 27 Jun 2024 10:20:15 +0900 Subject: [PATCH 15/21] Update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f43908..49b1d5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,4 +24,4 @@ jobs: - name: Run Cypress tests env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - run: npm run test --record --key "$CYPRESS_RECORD_KEY" + run: npm run test From ca7039fa85ffa44dbc0ee84a63dba2dd592183b8 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Thu, 27 Jun 2024 10:24:40 +0900 Subject: [PATCH 16/21] Update --- .husky/pre-push | 2 +- package.json | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index e37998f..b309e01 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1 +1 @@ -npm run test +npm run local_test diff --git a/package.json b/package.json index a8591c5..33f70a7 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,10 @@ "build": "react-scripts build", "eject": "react-scripts eject", "cy:open": "cypress open", - "cy:run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", + "cy:run": "cypress run", "test": "start-server-and-test start 3000 cy:run", + "cy:record_run": "dotenv -- cypress run --record --key=$CYPRESS_RECORD_KEY", + "local_test": "start-server-and-test start 3000 cy:record_run", "prepare": "husky" }, "eslintConfig": { From a1a6a44d58a83369f2095bc4aa9705d0e05e9495 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Tue, 6 Aug 2024 13:14:56 +0900 Subject: [PATCH 17/21] Update --- .github/workflows/ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49b1d5c..91c9ce8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,9 @@ jobs: with: node-version: '16.20.2' - - name: Install dependencies - run: npm install - - - name: Run Cypress tests - env: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - run: npm run test + - name: Cypress run + uses: cypress-io/github-action@v6 + with: + start: yarn start + wait-on: 'http://127.0.0.1:3000' + group: 'sample-test' From ba4c305eb5fc279e5279a4965fe1ff60cc5aeed0 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Tue, 6 Aug 2024 13:17:52 +0900 Subject: [PATCH 18/21] Update --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91c9ce8..c70f543 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,10 +17,12 @@ jobs: uses: actions/setup-node@v4 with: node-version: '16.20.2' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - name: Cypress run uses: cypress-io/github-action@v6 with: start: yarn start wait-on: 'http://127.0.0.1:3000' - group: 'sample-test' + cache-key: ${{ runner.os }}-cypress-${{ hashFiles('**/yarn.lock') }}- From 116bd4b9404cb4924bedc772688f3cebc04c27b0 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Tue, 6 Aug 2024 13:21:01 +0900 Subject: [PATCH 19/21] Update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c70f543..02cb1a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,4 +25,4 @@ jobs: with: start: yarn start wait-on: 'http://127.0.0.1:3000' - cache-key: ${{ runner.os }}-cypress-${{ hashFiles('**/yarn.lock') }}- + cache-key: ${{ runner.os }}-cypress-${{ hashFiles('**/package-lock.json') }}- From 9ef34151d7cee996dc0438aebec7aba7a85349de Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Tue, 6 Aug 2024 13:26:03 +0900 Subject: [PATCH 20/21] empty commit for triggering CI From aa4797289277dcb33a36d252ea31fc7c8559c0f5 Mon Sep 17 00:00:00 2001 From: ryo-kozin Date: Fri, 9 Aug 2024 07:40:39 +0900 Subject: [PATCH 21/21] update --- .github/workflows/ci.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02cb1a8..cf95e43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,11 +4,16 @@ on: pull_request: branches: - main + push: + branches: + - main jobs: build: runs-on: ubuntu-latest + if: (github.event_name != 'pull_request' || github.event.pull_request.merged == false) + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -20,9 +25,13 @@ jobs: cache: 'npm' cache-dependency-path: '**/package-lock.json' + - name: Install Dependencies + run: npm install --prefer-offline + - name: Cypress run uses: cypress-io/github-action@v6 with: - start: yarn start + install: false + start: npm start wait-on: 'http://127.0.0.1:3000' cache-key: ${{ runner.os }}-cypress-${{ hashFiles('**/package-lock.json') }}-