Skip to content

Commit c086ae7

Browse files
committed
add cypress e2e testing
1 parent b68be32 commit c086ae7

File tree

7 files changed

+75
-14437
lines changed

7 files changed

+75
-14437
lines changed

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)