zordius / gulp-jsx-coverage

deprecated
https://www.npmjs.com/package/gulp-jsx-coverage
Other
34 stars 10 forks source link

How to connect Phantom.js #18

Closed naydenow closed 8 years ago

naydenow commented 8 years ago

Hi, how to connect Phantom js?

zordius commented 8 years ago

Sorry, I can not get your point. Do you mean running tests in phantom.js?

naydenow commented 8 years ago

I want to run tests using the window object startup I get an error: ReferenceError: window is not defined

zordius commented 8 years ago

If you are targeting to test in browser environment, you should use browser side technology. For example, you may need to pack your test+target scripts with browerify or webpack, then try to execute tests in your browser. If the tests works well in your browser, then you can move tests into phantomjs.

Another way to do browser tests is by protractor, it also supports phantomjs.

If you are targeting to test in nodejs environment but you like to have DOM API, you may use jsdom to simulate browser environment inside nodejs. Refer to https://github.com/zordius/gulp-jsx-coverage/blob/master/test/test2.jsx#L20 you can see an example which try to test react.js component rendering without browser nor phantomjs.