Closed JohanObrink closed 5 years ago
@JohanObrink thanks for the PR! I'm curious, since I haven't used vash with jest before: was an error being thrown?
published as 0.12.5!
@kirbysayshi No worries :)
It threw an error in lib/helpers/layout.js
on row 51 saying cannot call function "normalize" of undefined
. This is because of path
only being required if window
is undefined
. Jest sets global.window
to an instance of jsdom :/
You can try it out by forking https://github.com/JobtechSwe/mydata-operator and running the tests against version 0.12.4
Ok, that makes sense. Thanks for explaining! I haven't used jest for server-side tests (and of course this code was written before jest was really a huge thing haha).
Yeah... Jest is good since they run on a lot of platforms. Their assumptions do clash with the assumptions of a lot of Node libs though. Vash is far from the only lib that uses the existance of window
to determine the runtime environment :(
Layout used a "hacky guard" to prevent non-nodejs erroring by checking for the existance of
window
. In Jest this breaks sincewindow
is polyfilled using jsdom. The new "hacky guard" is checking forglobal
not being undefined.Also ran
npm audit fix
to upgrade a dependency with an identified vulnerability.