-
Notifications
You must be signed in to change notification settings - Fork 34
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: use snapshot #151
test: use snapshot #151
Conversation
21ec175
to
5196988
Compare
All review comments of #143 have been applied in this PR |
5196988
to
3cd38e9
Compare
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.
Left a couple of comments - Review of test/index.test.ts still pending.
|
||
test("insertStyle shouldn't choke when window is undefined", (t) => { | ||
delete global["window"]; | ||
t.throws(() => !window); |
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.
throw
test seems un-required here - reasoning?
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 can only guess the reason... this assertion is already present on the main branch
rollup-plugin-sass/test/style.test.ts
Line 31 in 0425739
t.throws(() => !window); |
the tests are probably executed in strict
mode so an error occurs if you access a variable that doesn't exists
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.
Do we need to track these *.snap files?
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.
https://github.com/avajs/ava/blob/main/docs/04-snapshot-testing.md
Say you have
~/project/test/main.js
which contains snapshot assertions. AVA will create two files:
~/project/test/snapshots/main.js.snap
~/project/test/snapshots/main.js.md
The first file contains the actual snapshot and is required for future comparisons.
The second file contains your snapshot report. It's regenerated when you update your snapshots.
If you commit it to source control you can diff it to see the changes to your snapshot.
3cd38e9
to
4bbbaca
Compare
@marcalexiei Hey, right - apologies about that - have been uber swamped lately - |
Part of #141
Unit tests updates
Snapshots
Snapshots are used whenever is possible.
Warning
It was not possible to use them in all tests.
Detailed explanation
watchlist
Can't use snapshot since is comparing rollup properties with file system files.
However I was able to simplify the logic (I created a separate commit).
output
Using snapshot here is not feasible due to rollup:
It looks like that, randomly, plugin
transform
is called first onactual_b
and then onactual_a
instead of calling transform onactual_a
and then onactual_b
.So instead of having:
you end up having
But only some times.
This looks like a rollup bug:
Right now on
main
branchshould support output as function
sometimes fails for the exact same reason.Also on other tests involving
output
, assertions are written usingindexOf !== -1
logic.I assume it's because of this bug.
E.g.:
rollup-plugin-sass/test/index.test.ts
Lines 265 to 268 in 0425739
Right now there isn't much we can do.
I'm going to add a code comment on
options.output.test.ts
referencing this PRinsertStyle.test.ts
– replacejsdom
withhappy-dom
Since the test are quite simple I opted out to switch
jsdom
tohappy-dom
(less dependencies and faster)Additional changes
ava
@ava/typescript
nyc
sinon
@types
forsinon
icss-utils