-
Notifications
You must be signed in to change notification settings - Fork 12
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
test advanced checkpoints #230
base: main
Are you sure you want to change the base?
Conversation
trieloff
commented
Jul 4, 2024
- test(index): test block visibility, resource loading
- test(index): add test for form submissions
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
==========================================
+ Coverage 93.37% 94.17% +0.80%
==========================================
Files 5 5
Lines 498 498
==========================================
+ Hits 465 469 +4
+ Misses 33 29 -4 ☔ View full report in Codecov by Sentry. |
|
||
await sendMouse({ type: 'click', position: [10, 10] }); | ||
|
||
assert(window.called.some((call) => call.checkpoint === 'viewmedia'), 'viewmedia checkpoint missing'); |
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 is a bad practice: the tests share the same execution context, i.e. they can interfere between each others. This one can for example trigger a missingresource
you do not check here. If implementation for next test is broken (i.e. fetch does not fire a missingresouce
, test will be successful but implementation is wrong.
Several todos:
- before / after each test, clean up the
called
stack - in each test, test for exact equality - if order is random, at least test for window.called.length === 4
If this is not doable in one file, split into multiple files
setTimeout(resolve, 100); | ||
}); | ||
|
||
assert(window.called.some((call) => call.checkpoint === 'missingresource'), 'missingresource checkpoint missing'); |
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.
You are testing missingresource
in a loadblock
test file. Either rename the file or move to dedicated test file.
await new Promise((resolve) => { | ||
setTimeout(resolve, 2000); | ||
}); | ||
assert(window.called.some((call) => call.checkpoint === 'formsubmit'), 'formsubmit checkpoint missing'); |
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.
Same, testing formsubmit
in loadblock
file...
@@ -0,0 +1,4 @@ | |||
<div> |
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.
Move file into a fixtures
subfolder to separate test files and resources (same for image)