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

Issue/137 playwright setup #138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
84 changes: 84 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

# testing
/coverage
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
WULCAN marked this conversation as resolved.
Show resolved Hide resolved

# next.js
/.next/
Expand Down
27 changes: 27 additions & 0 deletions webapp/TESTING.md
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Collaborator

@WULCAN WULCAN Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the URL does not lead to any documentation.

Screencast.from.2024-10-27.10-10-49.webm

Let's update the URL to something that resolves in documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change to correct URL


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`
1 change: 1 addition & 0 deletions webapp/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ module.exports = {
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: ['<rootDir>/integrationTesting'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modulePathIgnorePatterns is for making modules non-require()-able in the test environment. Why do we want to do that?

https://jestjs.io/docs/configuration#modulepathignorepatterns-arraystring

If it is for ignoring Playwright tests, there is a testPathIgnorePatterns that we can use: https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You understood my intent correctly, It is to exclude integration test from running when running jest. :)

Updating this too.

};
7 changes: 6 additions & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Comment on lines +34 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two new devDependencies are what npm init playwright@latest adds.

We already have a devDependency on @types/node declared in the root package so we do not need to add a new one here.

Lyra does not require Node 22 yet so we should not to update types to types for Node 22.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright! :)

}
}
6 changes: 6 additions & 0 deletions webapp/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
WULCAN marked this conversation as resolved.
Show resolved Hide resolved
reporter: [['html', { open: 'never' }]],
WULCAN marked this conversation as resolved.
Show resolved Hide resolved
testDir: './integrationTesting/tests',
WULCAN marked this conversation as resolved.
Show resolved Hide resolved
});