test: Add snapshot tests#169
test: Add snapshot tests#169its-me-abhishek merged 2 commits intoCCExtractor:mainfrom AntoineDeveloppeur:jestSnapshot
Conversation
|
hi @AntoineDeveloppeur , this implementation looks great overall, the snapshots residing in |
|
Thanks for your feedback. I agree with your suggestions and will handle it. |
|
Hi @its-me-abhishek pull request is now ready for review |
|
Please remove all the tests from |
|
@its-me-abhishek done |
its-me-abhishek
left a comment
There was a problem hiding this comment.
Please fix the prettier issues
|
I fixed Devlog.test LocalTime issue I run |
yeah you;d need to revert that in order to make these workflows run |
That's great! I was reading this a while ago while looking for a similar fix. Might be a good read. As of now currently One test is failing @ HomePage, please fix that, will merge it afterwards Edit: Typo |
- Add snapshot tests in the same file as rendering tests - Store snapshots in "__test__/__snapshots__" in the tested component folder - Update package.json with scripts to test snapshots only, all tests, or every test but snapshots - Update jest.setup and jest.config to modify aria and radix attributes to fixed values only for snapshot tests - Update @/frontend/README.md
context: Depending on load durging test this mock promise resolved fast. This bypassed loadingState to false
|
Thank you for the article and your patience. It appears that the test failing (HomePage rendering test) is not one that I implemented. First, I notice that : This test might be a flaky test. No control over the resolution of a promise while expecting to see :
In the last commit my proposal to improve this test |
* test: Add snapshot tests to all components (CCExtractor#163) - Add snapshot tests in the same file as rendering tests - Store snapshots in "__test__/__snapshots__" in the tested component folder - Update package.json with scripts to test snapshots only, all tests, or every test but snapshots - Update jest.setup and jest.config to modify aria and radix attributes to fixed values only for snapshot tests - Update @/frontend/README.md * fix: add homePage test resolve control of mockFetchTaskwarrierTasks context: Depending on load durging test this mock promise resolved fast. This bypassed loadingState to false


Description
Implement snapshot tests
Checklist
npx prettier --write .(for formatting)gofmt -w .(for Go backend)npm test(for JS/TS testing)Additional Notes
Obsolete note when not testing snapshots
When running npm run test:without-snapshot, Jest reports snapshots as obsolete. This message is unnecessary in this context and only serves as a distraction. I looked for a way to suppress it, but haven’t found a solution yet.
Test script logic
To ensure all tests are run before developers commit, I chose to keep the default
npm run testcommand for both rendering and snapshot tests. Here’s the current setup:No changes are needed for GitHub Actions, as it already runs
npm run test.Alternative Approach
An Alternative would be to separate test snapshot testing entirely :
and add a dedicated Github actions step for snapshot tests.
I believe the first option encourages developers to treat snapshots as integral tests, ensuring better compliance. However, I can implement the alternative if preferred.