Skip to content

Commit

Permalink
test: update cypress, add component testing in CI, add Cypress Cloud (#…
Browse files Browse the repository at this point in the history
…153)

* configure baseUrl in one place for e2e tests

* update Cypress version to latest

* add component testing to the github action

* add cypress project id

* add steps to run tests in parallel

* skip building

* skip building

* remove extra branch, update container count
  • Loading branch information
marktnoonan committed Jul 21, 2023
1 parent 4d7ce64 commit f11cb83
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 27 deletions.
65 changes: 57 additions & 8 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,74 @@ jobs:
- run: npm ci
- run: npm run format

cypress-install:
runs-on: ubuntu-latest
container: cypress/browsers:node16.16.0-chrome107-ff107-edge
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cypress install
uses: cypress-io/github-action@v5.8.3
with:
# Disable running of tests within install job
runTests: false

cypress-run:
cypress-run-e2e:

name: Run Cypress Tests
name: Run End-to-End Tests
needs: cypress-install
runs-on: ubuntu-latest
container: cypress/browsers:node12.18.3-chrome87-ff82
container: cypress/browsers:node16.16.0-chrome107-ff107-edge
strategy:
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
- name: Cypress run
uses: cypress-io/github-action@v5.0.9
with:
node-version: 16
- run: npm ci
# Specify Browser since container image is compile with Firefox
browser: chrome
start: npm run dev
wait-on: 'http://localhost:3000'
record: true
parallel: true
group: e2e
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cypress-run-component:

name: Run Component Tests
needs: cypress-install
runs-on: ubuntu-latest
container: cypress/browsers:node16.16.0-chrome107-ff107-edge
strategy:
# don't fail the entire matrix on failure
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cypress run
uses: cypress-io/github-action@v5.0.9
with:
# Specify Browser since container image is compile with Firefox
browser: chrome
start: npm run dev
component: true
record: true
parallel: true
group: component
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from "cypress";

export default defineConfig({
projectId: "1nng13",
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
// implement node event listeners here
},
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/contactuspage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

describe("Contact Us Image Rendering", () => {
beforeEach(() => {
cy.visit("http://localhost:3000/contact", { timeout: 30000 });
cy.visit("/contact", { timeout: 30000 });
});

it("Image rendering on desktop", () =>{
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import validateFooter from "../util/validateFooter";

describe("Homepage", () => {
beforeEach(() => {
cy.visit("http://localhost:3000", { timeout: 30000 });
cy.visit("/", { timeout: 30000 });
});

it("should display the homepage", () => {
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@vitejs/plugin-react": "^3.1.0",
"autoprefixer": "^10.4.7",
"babel-loader": "^8.2.5",
"cypress": "^12.12.0",
"cypress": "^12.17.1",
"eslint": "8.26.0",
"eslint-config-next": "^13.2.4",
"eslint-plugin-storybook": "^0.6.11",
Expand Down

0 comments on commit f11cb83

Please sign in to comment.