Spawning Snowpack projects on-demand for testing purposes.
Status: work in progress, currently focused on testing Snowpack HMR behaviour.
git clone git@github.com:rixo/snowgun.git
cd snowgun
yarn
yarn test
Snowgun is powered by poorly lightly documented zoar test runner, and zorax extensions (themselves built upon the great zora essentialist testing library).
Here are a few tips about the most useful commands you can use...
NOTE zoar
is aliased as test
in package.json
, but all the following commands are really just running zoar
itself... You could just as well use yarn zoar
or node_modules/.bin/zoar
.
yarn test --watch
In watch mode, pressing Enter will rerun the tests.
Also, further options can be passed / changed interactively, without the need to restart the test runner. The available options are essentially the same as the argument accepted by the cli (see bellow for a curated selection).
The interactive console accepts options in long (e.g. --filter
) or shortcut (e.g. -f
), with or without the leading --
/ -
.
Adding ?
after the option name will display the current option value. Adding !
will reset the option to false
/ empty.
Entering just !!
(or pressing Esc) will reset all options to their initial value (that is, the value that have been passed to the cli command).
So you can do something like this ($
is the term, >
is zoar's interactive console):
$ zoar -w -f sanity
...
> f? # show the current filter
> f! # reset the filter
...
> ls # print matched files (switches to ls mode)
> f single # change the filter (and rerun ls)
> run # run the tests (switches back to run mode)
...
> ib # debug the test in Node (short for --inspect-brk)
...
> ib! # stop debugging in Node
...
> e OPEN # open the browser while running test (allowing for in-browser debugging)
...
> e? # display current env variables that are passed to the test process
> e! # stop opening browser while running test
...
> !! # reset to initial options (`-f sanity`, in this example)
Help:
yarn test --help
Run test process with --inspect-brk
(allow debugging Snowpack code):
yarn test --inspect-brk
Open Playwright browser while running tests (with slowmo and also cancelling tests timeout -- allow debugging the JS running in the browser, by adding debugger
in the fixtures' JS):
yarn test --env OPEN
Display brower console output:
yarn test --env CONSOLE
Filter tests by file name:
yarn test --filter sanity
Show the files matched by your filter:
yarn test --ls
Filter tests by test name:
yarn test --grep serve
Print all the tests matched by the filters (instead of running them):
yarn test --print
Modifier options can all be mixed and matched:
yarn test --filter sanity --grep serve --ls
yarn test --filter sanity --grep serve --print