-
Notifications
You must be signed in to change notification settings - Fork 11
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
Playwright tests #1832
Draft
fhenrich33
wants to merge
88
commits into
master
Choose a base branch
from
playwright-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Playwright tests #1832
Changes from all commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
4a5e69d
infra: generated mocks, msw setup
fhenrich33 a45d34e
infra: remove graphql-codegen package and plugins, setup playwright, …
fhenrich33 56b04e2
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 0787be2
fix: fragment usage
fhenrich33 8d15663
infra: update graphql-gen script, fixtures
fhenrich33 f5c7ba6
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 0733d47
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 eea367a
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 94c2629
refactor: move msw handlers import to source
fhenrich33 27d131f
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 cb1c566
chore: file line end
fhenrich33 043488d
refactor: remove old test setup
fhenrich33 5934253
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 09a8add
refactor: remove old test setup
fhenrich33 29fe187
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 9ccc9f1
feat: update fixture objects and msw responses with mutations
fhenrich33 c5c9f64
feat: update fixture objects and msw responses with mutations
fhenrich33 512b5d9
feat: update fixture objects and msw responses with mutations
fhenrich33 5442c6e
feat: update fixture objects and msw responses with mutations
fhenrich33 c50b23c
feat: update fixture objects and msw responses with mutations
fhenrich33 2a14328
test: persist some box mutations in msw
fhenrich33 f1994f9
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 1572eac
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 b6ca365
infra: use workspace prettier config
fhenrich33 7e169c1
feat: msw handlers (except shipments, transfer agreements, box history)
fhenrich33 a043bc7
feat: msw handlers for shipments and transfer agreements queries
fhenrich33 2838fe8
test: qrCode fake cam feed
fhenrich33 16ce8be
feat: msw handler last mutations wip
fhenrich33 fdb83f8
feat: msw handler last mutations wip
fhenrich33 77547ff
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 7b9069a
fix: tag labels on box edit in msw
fhenrich33 7f127a8
chore: add todo
fhenrich33 91b18eb
infra: enable gpg commit signing for vscode
fhenrich33 feed8db
chore: update msw todo
fhenrich33 ac98d5c
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 c6d9c3a
docs: playwright adr draft
fhenrich33 093a1b4
test: infer operation name from graphql operation
fhenrich33 51d2129
test: wip/draft script to auto generate handlers and mocks
fhenrich33 1024d3f
test: wip/draft script to auto generate handlers and mocks
fhenrich33 ff81336
chore: remove draft handle and data generator
fhenrich33 668d32d
infra: WIP playwright CI job
fhenrich33 d7cfe4a
infra: WIP playwright CI job
fhenrich33 3e75a5f
infra: WIP playwright CI job
fhenrich33 8294d31
infra: WIP playwright CI job
fhenrich33 cb87d5e
infra: WIP playwright CI job
fhenrich33 3e81ab4
infra: WIP playwright CI job
fhenrich33 a7d3312
infra: WIP playwright CI job
fhenrich33 4149319
infra: WIP playwright CI job
fhenrich33 69e2371
infra: WIP playwright CI job
fhenrich33 bfc8560
infra: WIP playwright CI job
fhenrich33 b3e0181
infra: WIP playwright CI job
fhenrich33 71858b0
infra: WIP playwright CI job
fhenrich33 c0b9905
infra: WIP playwright CI job
fhenrich33 5f2fa26
infra: WIP playwright CI job
fhenrich33 d58d5d5
infra: playwright CI job
fhenrich33 d1d8e72
test: qrcode tests
fhenrich33 363d2d0
test: give bigger timeout for qrcode tests
fhenrich33 31b9f96
infra: add generated state.json to gitignore
fhenrich33 a0b6cfc
test: simplify CI test command, WIP fix qrcode in CI
fhenrich33 a744e21
infra: fix playwright server command
fhenrich33 510d713
infra: wip run playwright with node-executor
fhenrich33 30278d8
infra: wip run playwright with node-executor
fhenrich33 1a2c185
test: WIP fix qrcode in CI
fhenrich33 51dcf41
test: WIP fix qrcode in CI
fhenrich33 b30410e
infra: run playwright with node-executor
fhenrich33 e132d3d
test: WIP fix qrcode in CI
fhenrich33 516fcfd
test: local only tests for specs that don't work in CI
fhenrich33 f327be8
chore: remove unused if
fhenrich33 8dedd7f
chore: mutation TODOs
fhenrich33 e042935
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 55d8b0d
docs: update testing section for the FE README
fhenrich33 9610e32
docs: update ADR
fhenrich33 3fc1483
docs: update ADR
fhenrich33 ca9bdd6
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 b07441c
docs: update FE README
fhenrich33 11beaaa
Merge branch 'master' into playwright-tests
fhenrich33 cecad45
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 e87ce1e
docs: add and fix missing context for ADR and FE README
fhenrich33 58298c1
Merge branch 'master' into playwright-tests
fhenrich33 18e7b75
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 dd15fb4
Merge branch 'master' of https://github.com/boxwise/boxtribute into p…
fhenrich33 a11c89c
chore: remove unused stories files
fhenrich33 f895937
chore: remove unused files from previous test setup
fhenrich33 7502a3e
infra: remove unused packages
fhenrich33 d09ca08
fix: wrong font path
fhenrich33 c6dc12b
infra: wip multi auth setup, remove previous config, global load prop
fhenrich33 a76bde5
test: mock qr reader setup
fhenrich33 24544b2
test: adjust and add more specs
fhenrich33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# ADR: Use Playwright for Application, Integration and Component Testing | ||
|
||
Author: [Felipe](https://github.com/fhenrich33) | ||
|
||
Reviewed by: [Roanna K](https://github.com/aerinsol) | ||
|
||
## Status | ||
|
||
Proposed, Implementing | ||
|
||
## Context | ||
|
||
The current testing setup for the Boxtribute front-end project uses React Testing Library and Vitest for unit and integration tests. While these tools are effective for testing individual components and their interactions, the tests usually aren't fully 1-1 representative of what the user will experience. E2E and more involved integration testing are crucial for ensuring that the application works correctly from the user's perspective, covering the entire workflow from start to finish. | ||
|
||
Additionally, we use Mock Service Worker (MSW) to mock API requests during tests (and sometimes development) to avoid hitting the real development server and database during tests. This allows us to test the application in isolation and ensure consistent and fast test results. | ||
|
||
## Decision Drivers | ||
|
||
1. **Comprehensive Testing**: We need a testing framework that can simulate real user interactions, test the application as a whole, and handle integration tests with mocked API requests. | ||
2. **Cross-Browser Testing**: The ability to test the application across different browsers to ensure compatibility. | ||
3. **Ease of Use**: The testing framework should be easy to set up and use, with good documentation and community support. | ||
4. **Performance**: The framework should be fast and efficient, minimizing the impact on the development workflow. | ||
5. **Integration with CI/CD**: The framework should integrate well with our existing CI/CD pipeline. | ||
|
||
## Considered Options | ||
|
||
1. **React Testing Library + Vitest** | ||
|
||
- Pros: | ||
- Well-suited for unit and integration tests. | ||
- Good community support and documentation. | ||
- Easy to set up and use for isolated testing. | ||
- Cons: | ||
- Limited to testing individual components and their interactions. | ||
- Does not provide comprehensive application testing capabilities (in comparison to Playwright). | ||
- Runs against a mocked DOM structure (jsdom) instead of a real browser, which leads to flakiness and unreliability. | ||
- No built-in support for cross-browser testing. | ||
|
||
2. **Playwright** | ||
- Pros: | ||
- Comprehensive application, integration, and component testing capabilities. | ||
- Tests against the real DOM, as even in headless mode the tests run inside a real browser. | ||
- Supports cross-browser testing (Chromium, Firefox, WebKit). | ||
- Easy to set up and use with excellent documentation. The API for test specs is very similar to React Testing Library. | ||
- Ability to generate tests by using the app. See https://playwright.dev/docs/codegen-intro. | ||
- Can still run isolated component tests. See https://playwright.dev/docs/test-components. | ||
- Can run visual diffing. See https://playwright.dev/docs/test-snapshots. | ||
- Fast and efficient, with parallel test execution. Might not match React Testing Library speed but gets close while testing in a real environment. | ||
- Integrates well with CI/CD pipelines in headless mode. | ||
- Cons: | ||
- Additional learning curve for advanced use cases. | ||
- Extra setup may be required for advanced use cases. | ||
- Slightly slower than React Testing Library for sequential test runs (alleviated by parallel runs). | ||
|
||
## Decision | ||
|
||
We have decided to adopt Playwright for application, integration, and component testing in the Boxtribute front-end project. Playwright provides comprehensive testing capabilities, supports cross-browser testing, and integrates well with our existing CI/CD pipeline. Additionally, Playwright can be used with Mock Service Worker (MSW) to mock API requests, allowing us to test the application in isolation, while faithfully mimicking the real server since the mocks infer the data types from the GraphQL Schema. Vitest will still be used for individual TypeScript functions and modules. | ||
|
||
## Consequences | ||
|
||
- **Positive**: | ||
|
||
- Improved test coverage with comprehensive application, integration, and component tests. | ||
- Ability to test the application across different browsers. | ||
- Fast testing with parallel test execution, while being more faithful to how a user will experience the app. | ||
- Better integration with our CI/CD pipeline. Less prone to flakiness. | ||
- Consistent test results by mocking API requests with MSW based on our GraphQL Schema. | ||
|
||
- **Negative**: | ||
- Additional learning curve for developers. | ||
- Potential need for additional setup for advanced use cases. | ||
- Heavier Development and CI/CD setup, as we install real browsers as dependencies. | ||
|
||
## References | ||
|
||
- [Playwright Documentation](https://playwright.dev/docs/intro) | ||
- [React Testing Library Documentation](https://testing-library.com/docs/react-testing-library/intro) | ||
- [Vitest Documentation](https://vitest.dev/) | ||
- [Mock Service Worker Documentation](https://mswjs.io/docs/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the main Pro argument is that you can easily generate mock data @fhenrich33 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be the benefit of gql.tada, used with MSW request handlers. Playwright does have a very similar mocking capability as MSW, but we use the latter to allow us to mock yet-to-be-implemented schemas in the future.