From badf15f825ad07a22b158cb9f7fbd1518d2de325 Mon Sep 17 00:00:00 2001 From: a-jaxell Date: Sat, 26 Oct 2024 15:27:07 +0200 Subject: [PATCH 1/3] Add testing.md --- webapp/TESTING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 webapp/TESTING.md diff --git a/webapp/TESTING.md b/webapp/TESTING.md new file mode 100644 index 0000000..56ca8b9 --- /dev/null +++ b/webapp/TESTING.md @@ -0,0 +1,27 @@ +# Testing + +This contains information on how to run different tests and add new tests for Lyra. + +We are using Playwright to test integration of features. +Read the documentation at [playwright.dev/docs](https://playwright.dev/docs) + +Jest is used to write both integration and unit tests. +[jest.io/docs](https://jestjs.io/docs/getting-started) + +## Integration Tests + +Lyra uses Playwright together with Jest to test integration. + +All integration tests resources are located in the `/integrationTesting` folder. New tests should be added in the `/tests` folder. + +To run integration tests: + +`npm run playwright` + +## Unit tests + +Unit tests are written in Jest and located paralell to the unit they are written for. + +To run unit tests: + +`npm run test` \ No newline at end of file From 2e05c168cd9c34735c9c5a89e3129ad12c463ea7 Mon Sep 17 00:00:00 2001 From: a-jaxell Date: Sat, 26 Oct 2024 16:29:27 +0200 Subject: [PATCH 2/3] Setup playwright --- package-lock.json | 84 +++++++++++++++++++++++++++++++++++++ webapp/.gitignore | 4 ++ webapp/jest.config.js | 1 + webapp/package.json | 7 +++- webapp/playwright.config.ts | 8 ++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 webapp/playwright.config.ts diff --git a/package-lock.json b/package-lock.json index 0cf0cd4..6236b7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2248,6 +2248,22 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.2.tgz", + "integrity": "sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.48.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -9578,6 +9594,53 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.2.tgz", + "integrity": "sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==", + "devOptional": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.48.2" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.48.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.2.tgz", + "integrity": "sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==", + "devOptional": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/possible-typed-array-names": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", @@ -11246,8 +11309,29 @@ "simple-git": "^3.20.0", "yaml": "^2.3.3", "zod": "^3.22.4" + }, + "devDependencies": { + "@playwright/test": "^1.48.2", + "@types/node": "^22.8.1" } }, + "webapp/node_modules/@types/node": { + "version": "22.8.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.1.tgz", + "integrity": "sha512-k6Gi8Yyo8EtrNtkHXutUu2corfDf9su95VYVP10aGYMMROM6SAItZi0w1XszA6RtWTHSVp5OeFof37w0IEqCQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.8" + } + }, + "webapp/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, "webapp/node_modules/yaml": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.4.tgz", diff --git a/webapp/.gitignore b/webapp/.gitignore index 7507a42..bf5f86d 100644 --- a/webapp/.gitignore +++ b/webapp/.gitignore @@ -7,6 +7,10 @@ # testing /coverage +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ # next.js /.next/ diff --git a/webapp/jest.config.js b/webapp/jest.config.js index fb7feed..6811ee1 100644 --- a/webapp/jest.config.js +++ b/webapp/jest.config.js @@ -5,4 +5,5 @@ module.exports = { moduleNameMapper: { '@/(.*)': '/src/$1', }, + modulePathIgnorePatterns: ['/integrationTesting'] }; diff --git a/webapp/package.json b/webapp/package.json index 530fcdf..98ae8fd 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -10,7 +10,8 @@ "lint:eslint": "eslint .", "lint:eslint-fix": "eslint . --fix", "lint": "next lint", - "test": "jest" + "test": "jest", + "playwright": "npx playwright test" }, "dependencies": { "@emotion/react": "^11.11.4", @@ -28,5 +29,9 @@ "simple-git": "^3.20.0", "yaml": "^2.3.3", "zod": "^3.22.4" + }, + "devDependencies": { + "@playwright/test": "^1.48.2", + "@types/node": "^22.8.1" } } diff --git a/webapp/playwright.config.ts b/webapp/playwright.config.ts new file mode 100644 index 0000000..9e2fb49 --- /dev/null +++ b/webapp/playwright.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from '@playwright/test'; + +export default defineConfig({ + reporter: [ + ['html', {open: 'never'}] + ], + testDir: './integrationTesting/tests', +}); From 98d2d8b852d2df53c7ebdf6339a88fdf570e451d Mon Sep 17 00:00:00 2001 From: a-jaxell Date: Sat, 26 Oct 2024 16:45:08 +0200 Subject: [PATCH 3/3] Fix linting --- webapp/TESTING.md | 6 +++--- webapp/jest.config.js | 2 +- webapp/playwright.config.ts | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/webapp/TESTING.md b/webapp/TESTING.md index 56ca8b9..cebf534 100644 --- a/webapp/TESTING.md +++ b/webapp/TESTING.md @@ -1,8 +1,8 @@ # Testing -This contains information on how to run different tests and add new tests for Lyra. +This contains information on how to run different tests and add new tests for Lyra. -We are using Playwright to test integration of features. +We are using Playwright to test integration of features. Read the documentation at [playwright.dev/docs](https://playwright.dev/docs) Jest is used to write both integration and unit tests. @@ -24,4 +24,4 @@ Unit tests are written in Jest and located paralell to the unit they are written To run unit tests: -`npm run test` \ No newline at end of file +`npm run test` diff --git a/webapp/jest.config.js b/webapp/jest.config.js index 6811ee1..db022c2 100644 --- a/webapp/jest.config.js +++ b/webapp/jest.config.js @@ -5,5 +5,5 @@ module.exports = { moduleNameMapper: { '@/(.*)': '/src/$1', }, - modulePathIgnorePatterns: ['/integrationTesting'] + modulePathIgnorePatterns: ['/integrationTesting'], }; diff --git a/webapp/playwright.config.ts b/webapp/playwright.config.ts index 9e2fb49..8a6d0b3 100644 --- a/webapp/playwright.config.ts +++ b/webapp/playwright.config.ts @@ -1,8 +1,6 @@ import { defineConfig } from '@playwright/test'; export default defineConfig({ - reporter: [ - ['html', {open: 'never'}] - ], + reporter: [['html', { open: 'never' }]], testDir: './integrationTesting/tests', });