Skip to content

Commit ba14b3b

Browse files
authored
Add Cypress (#610)
Adds e2e framework to monorepo. Uses updated `yarn dev` and couchdb scripts / submodule together for manual testing of general workflows. Adds config for nightly run.
2 parents b68be32 + 457ab9e commit ba14b3b

File tree

9 files changed

+1639
-1792
lines changed

9 files changed

+1639
-1792
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,26 @@
55

66
version: 2
77
updates:
8-
# Configuration for minor and patch updates (grouped)
8+
# Configuration for all updates
99
- package-ecosystem: 'npm'
1010
directory: '/'
1111
schedule:
1212
interval: 'weekly'
13-
# Only allow minor and patch updates
14-
ignore:
15-
- dependency-name: '*'
16-
update-types: ['version-update:semver-major']
13+
# Group minor and patch updates
1714
groups:
18-
dependencies:
15+
minor-patch-dependencies:
1916
patterns:
2017
- '*'
18+
update-types:
19+
- 'minor'
20+
- 'patch'
2121
exclude-patterns:
2222
- '@types/*' # Exclude type definitions from grouping for better clarity
23+
# Handle major updates separately (they won't be grouped)
24+
# Limit the number of open PRs for major updates
25+
open-pull-requests-limit: 5
2326
labels:
2427
- 'dependencies'
25-
- 'minor-patch-update'
26-
27-
# Separate configuration for major version updates
28-
- package-ecosystem: 'npm'
29-
directory: '/'
30-
schedule:
31-
interval: 'monthly' # Check less frequently to avoid PR noise
32-
# Only include major updates
33-
ignore:
34-
- dependency-name: '*'
35-
update-types: ['version-update:semver-minor', 'version-update:semver-patch']
36-
# Don't group major updates so they can be reviewed individually
37-
open-pull-requests-limit: 5 # Limit the number of open PRs for major updates
38-
labels:
39-
- 'dependencies'
40-
- 'major-update'
41-
- 'breaking-change'
42-
assignees:
43-
- 'nilock'
28+
commit-message:
29+
prefix: 'deps'
30+
include: 'scope'

.github/workflows/e2e-tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: E2E Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
e2e-tests:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
submodules: 'recursive' # Get submodule for couchdb snapshot
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '18'
21+
cache: 'yarn'
22+
23+
- name: Setup Docker
24+
uses: docker/setup-buildx-action@v2
25+
26+
- name: Install dependencies
27+
run: yarn install
28+
29+
- name: Install Cypress
30+
run: yarn cypress install
31+
32+
- name: Run E2E tests
33+
run: |
34+
# Start the dev environment in background
35+
yarn dev &
36+
# Wait for the server to be ready
37+
npx wait-on http://localhost:8080
38+
# Run Cypress tests
39+
yarn cypress run
40+
# Clean up
41+
kill $(lsof -t -i:8080)
42+
yarn couchdb:stop
43+
44+
- name: Upload screenshots on failure
45+
uses: actions/upload-artifact@v3
46+
if: failure()
47+
with:
48+
name: cypress-screenshots
49+
path: cypress/screenshots
50+
51+
- name: Upload videos
52+
uses: actions/upload-artifact@v3
53+
if: always()
54+
with:
55+
name: cypress-videos
56+
path: cypress/videos

cypress.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const { defineConfig } = require('cypress');
2+
3+
module.exports = defineConfig({
4+
e2e: {
5+
baseUrl: 'http://localhost:5173', // package/vue vite dev server port
6+
supportFile: 'cypress/support/e2e.js',
7+
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
8+
setupNodeEvents(on, config) {
9+
// implement node event listeners here
10+
},
11+
},
12+
// increase the default timeout for slower operations
13+
defaultCommandTimeout: 10000,
14+
// Viewport configuration
15+
viewportWidth: 1280,
16+
viewportHeight: 800,
17+
});

cypress/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
videos/
2+
screenshots/
3+
downloads/
4+
cypress.env.json

cypress/e2e/smoke.cy.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
describe('Smoke Test', () => {
2+
it('should load the application', () => {
3+
cy.visit('/');
4+
5+
cy.get('h1') // find 'banner' element on front page
6+
.contains(/edu.*Quilt/)
7+
.should('be.visible');
8+
});
9+
});

cypress/support/commands.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// vue-skuilder/cypress/support/commands.js
2+
// This file contains custom commands for Cypress tests
3+
4+
// Add any custom commands you need, for example:
5+
6+
// -- Example: Custom command for login --
7+
// Cypress.Commands.add('login', (email, password) => {
8+
// cy.visit('/login');
9+
// cy.get('[data-cy="email-input"]').type(email);
10+
// cy.get('[data-cy="password-input"]').type(password);
11+
// cy.get('[data-cy="login-button"]').click();
12+
// });
13+
14+
// You can read more about custom commands here:
15+
// https://on.cypress.io/custom-commands

cypress/support/e2e.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// vue-skuilder/cypress/support/e2e.js
2+
// This is the main support file for Cypress E2E tests
3+
// You can add global configurations, commands, and hooks here
4+
5+
// Import commands.js using ES2015 syntax:
6+
import './commands';
7+
8+
// Alternatively you can use CommonJS syntax:
9+
// require('./commands')
10+
11+
// You can read more here: https://on.cypress.io/configuration
12+
13+
// cypress/support/e2e.js
14+
Cypress.on('uncaught:exception', (err) => {
15+
// Log the error for debugging
16+
console.log('Uncaught exception:', err.message);
17+
18+
// If the error is from PouchDB, ignore it
19+
if (err.message.includes('not_found') || err.message.includes('missing')) {
20+
return false; // Prevents Cypress from failing the test
21+
}
22+
return true; // Otherwise, fail the test
23+
});

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"couchdb:status": "node scripts/dev-couchdb.js status",
1111
"couchdb:remove": "node scripts/dev-couchdb.js remove",
1212
"postdev": "node scripts/dev-couchdb.js stop",
13+
"test:e2e": "cypress open",
14+
"test:e2e:headless": "cypress run",
15+
"ci:e2e": "yarn dev & wait-on http://localhost:5173 && cypress run; kill $(lsof -t -i:8080); yarn couchdb:stop",
1316
"build": "yarn workspace @vue-skuilder/common build && yarn workspace @vue-skuilder/vue build && yarn workspace @vue-skuilder/express build"
1417
},
1518
"private": true,
@@ -18,6 +21,9 @@
1821
],
1922
"packageManager": "yarn@4.6.0",
2023
"devDependencies": {
21-
"concurrently": "^9.1.2"
24+
"@types/cypress": "^1.1.6",
25+
"concurrently": "^9.1.2",
26+
"cypress": "^14.1.0",
27+
"wait-on": "^8.0.2"
2228
}
2329
}

0 commit comments

Comments
 (0)