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

WIP: Automated testing #402

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ module.exports = {
'plugin:prettier/recommended',
'plugin:vue/vue3-recommended',
'@vue/eslint-config-typescript',
'plugin:cypress/recommended',
'prettier',
'plugin:prettier/recommended',
],
plugins: ['prettier', '@typescript-eslint'],
plugins: ['prettier', '@typescript-eslint', 'cypress'],
rules: {
quotes: ['error', 'single'],
'prettier/prettier': [
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"tabWidth": 2
}
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
9 changes: 9 additions & 0 deletions cypress/e2e/first-test.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('My first test', () => {
beforeEach(() => {
cy.visit('/');
});

it('Opens the app', () => {
cy.get('#app').should('have.length', 1);
});
});
5 changes: 5 additions & 0 deletions 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"
}
39 changes: 39 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference types="cypress" />
// ***********************************************
// 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) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }

import '@testing-library/cypress/add-commands';
25 changes: 25 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************************
// 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')
beforeEach(() => {
const serverAddress = 'http://localhost:8095';
cy.log(`Setting MA server to ${serverAddress}`);
window.localStorage.setItem('mass_debug_address', serverAddress);
});
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"lint": "eslint . --fix --ignore-path .gitignore"
"lint": "eslint . --fix --ignore-path .gitignore",
"test": "concurrently 'yarn:dev' 'cypress open'",
"test:ci": "cypress ci"
},
"dependencies": {
"@intlify/unplugin-vue-i18n": "2.0.0",
Expand All @@ -31,15 +33,19 @@
"devDependencies": {
"@fontsource/roboto": "5.0.8",
"@intlify/unplugin-vue-i18n": "2.0.0",
"@testing-library/cypress": "10.0.1",
"@types/color": "3.0.6",
"@types/node": "20.11.20",
"@typescript-eslint/eslint-plugin": "7.0.0",
"@typescript-eslint/parser": "6.21.0",
"@vitejs/plugin-vue": "4.6.2",
"@vue/eslint-config-typescript": "12.0.0",
"@vue/tsconfig": "0.5.1",
"concurrently": "8.2.2",
"cypress": "13.6.6",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-cypress": "2.15.1",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-vue": "9.22.0",
"https-localhost": "4.7.1",
Expand Down
Loading
Loading