Browse Source

Add e2e tests to ci

Jeremie Pardou-Piquemal 3 years ago
parent
commit
1eba637dd0

+ 12 - 3
.circleci/config.yml

@@ -1,8 +1,10 @@
 version: 2.1
 orbs:
   node: circleci/node@1.1.6
+  cypress: cypress-io/cypress@1.25.0
+
 jobs:
-  build-and-test:
+  lint-and-build:
     executor:
       name: node/default
     environment:
@@ -16,7 +18,7 @@ jobs:
           steps:
             - run: npm install
             - run: npm run lint
-            - run: npm run build
+            - run: SKIP_PREFLIGHT_CHECK=true npm run build
             - run:
                 name: Netlify Deploy
                 command: npx netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --dir=build
@@ -41,9 +43,16 @@ jobs:
                 command: npx netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_ACCESS_TOKEN --dir=build --prod
 
 workflows:
+  e2etest:
+    jobs:
+      - cypress/run:
+          start: SKIP_PREFLIGHT_CHECK=true REACT_APP_SOCKET_URL=https://public.jeremiez.net/ REACT_APP_SOCKET_PATH=/wamp/socket.io CI=true npm start
+          wait-on: "http-get://localhost:3000"
+          no-workspace: true
+          store_artifacts: true
   build-and-test:
     jobs:
-      - build-and-test:
+      - lint-and-build:
           filters:
             branches:
               ignore:

+ 3 - 1
cypress.json

@@ -1 +1,3 @@
-{}
+{
+  "baseUrl": "http://localhost:3000"
+}

+ 1 - 1
cypress/integration/board.spec.js

@@ -2,7 +2,7 @@ describe("Board interactions", () => {
   beforeEach(() => {
     cy.viewport(1000, 600);
     cy.visit("/");
-    cy.contains("I want play...").click();
+    cy.contains("I want play...", { timeout: 5000 }).click();
     cy.contains("Menu").click();
     cy.contains("Test game").click();
     // Way board loading

+ 1 - 1
cypress/integration/item.spec.js

@@ -2,7 +2,7 @@ describe("Item interactions", () => {
   beforeEach(() => {
     cy.viewport(1000, 600);
     cy.visit("/");
-    cy.contains("I want play...").click();
+    cy.contains("I want play...", { timeout: 5000 }).click();
     cy.contains("Menu").click();
     cy.contains("Test game").click();
 

+ 1 - 1
cypress/integration/selection.spec.js

@@ -2,7 +2,7 @@ describe("Selection action", () => {
   beforeEach(() => {
     cy.viewport(1000, 600);
     cy.visit("/");
-    cy.contains("I want play...").click();
+    cy.contains("I want play...", { timeout: 5000 }).click();
     cy.contains("Menu").click();
     cy.contains("Test game").click();
     // Way board loading

File diff suppressed because it is too large
+ 833 - 106
package-lock.json


+ 5 - 3
package.json

@@ -30,7 +30,7 @@
     "react-i18next": "^11.7.0",
     "react-router": "^5.2.0",
     "react-router-dom": "^5.2.0",
-    "react-scripts": "3.4.1",
+    "react-scripts": "^3.4.0",
     "react-use-localstorage": "^3.4.1",
     "react-zoom-pan-pinch": "^1.6.1",
     "recoil": "0.0.7",
@@ -48,7 +48,8 @@
     "server": "nodemon src/server.js",
     "i18n:scanner": "i18next-scanner --config i18next-scanner.config.js 'src/**/*.{js,jsx}'",
     "cypress:open": "LANGUAGE=en cypress open",
-    "cypress:run": "LANGUAGE=en cypress run"
+    "cypress:run": "LANGUAGE=en cypress run",
+    "e2e": "npm start && wait-on http://localhost:3000 && LANGUAGE=en cypress run"
   },
   "eslintConfig": {
     "extends": "react-app"
@@ -78,6 +79,7 @@
     "i18next-scanner": "^2.11.0",
     "netlify-cli": "^2.54.0",
     "nodemon": "^2.0.4",
-    "prettier": "2.0.5"
+    "prettier": "2.0.5",
+    "wait-on": "^5.1.0"
   }
 }

Some files were not shown because too many files changed in this diff