chromeless icon indicating copy to clipboard operation
chromeless copied to clipboard

Proposal: unit tests

Open geoffdutton opened this issue 7 years ago • 2 comments

I'm proposing this unit testing setup which replaces Ava and NYC with Jest. I'm proposing Jest over Ava/NYC due to the mocking features and built in coverage. Jest also supports a preprocessor (using ts-jest), which was smoother than running tsc -w & ava -w. I also selfishly have more experience with Jest testing. Is anyone opposed to using Jest?

With regards to debugging, especially when unit testing, with Node 8 I could not get break points to hit in Webstorm. Switching to Node 7 fixed that.

The only major changes are a few spots where the CDP port wasn't being passed, rather it was defaulting to 9222. For example, in utils.ts, the setViewPort function was calling CDP.Version() without passing any CDP options.

Otherwise, I've mainly added unit tests. There shouldn't be any breaking changes.

This is the first time I've worked with TypeScript, so I'd welcome any feedback of my changes.

Let me know your thoughts. Thanks!

geoffdutton avatar Aug 07 '17 02:08 geoffdutton

I'm working on the merge conflicts for the latest master branch (1.2.0). I should've updated it before I opened this PR--my bad.

geoffdutton avatar Aug 07 '17 03:08 geoffdutton

I have it up to 98% coverage now: https://coveralls.io/github/geoffdutton/chromeless?branch=jest-tests

Any thoughts around this? Should I create some more functional tests?

geoffdutton avatar Aug 14 '17 14:08 geoffdutton