Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configure Cypress #222

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Cypress

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create .env file (backend)
working-directory: ./publish-backend
run: cp .env.example .env
- name: create .env file (frontend)
working-directory: ./publish-frontend
run: cp sample.env.local .env.local
- name: install packages (frontend)
working-directory: ./publish-frontend
run: npm install
- name: install packages (backend)
working-directory: ./publish-backend
run: npm install
- name: Import strappi config
working-directory: ./publish-backend
run: |
docker compose up -d && wait
npm run cs export
docker compose down
- name: seed data
working-directory: ./publish-backend
env:
SEED_DATA: true
run: |
docker compose up -d && wait
- name: Cypress run
uses: cypress-io/github-action@v6
with:
working-directory: ./publish-frontend
start: npm run develop
wait-on: 'http://localhost:3000, http://localhost:1337'
wait-on-timeout: 120
env:

7 changes: 7 additions & 0 deletions publish-frontend/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000'
}
});
6 changes: 6 additions & 0 deletions publish-frontend/cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('template spec', () => {
it('is possible to login', () => {
cy.visit('/');
cy.contains('Sign in').click();
});
});
5 changes: 5 additions & 0 deletions publish-frontend/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": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions publish-frontend/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 publish-frontend/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.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')
Loading
Loading