Testing Javascript via jasmine-node OR html page (interchangeably)
For my WDI class at General Assembly, we wanted to write some specs and be able to run them either in jasmine-node OR from a jasmine html page (a SpecRunner), interchangeably. After some experimentation, I found I could a add simple conditional to the spec file to require the code file (via node) if I wasn’t in a browser. The conditional just checks for existence of `window`. I created a gist with a working example. The important code is: if (typeof window === 'undefined’).
|
|
comments powered by Disqus