Wednesday, 24 May 2017

Run jest with electron instead of node

To make a long story short, I'd like to run my jest tests (using CLI) with electron instead of node.

It's relevant when using native module, because you need to build them using electron header while jest run them using plain node. So I must either build my native modules for my app (at least in dev mode) or my tests, I can't have both to work.

In this thread they propose to use mocha, but I want to use jest, which is far more advanced and interact well with React. Note that I don't want to mock the native module, since I write integration tests.

I opened an issue about the zmq github repo. One proposed solution is "to target your tests using ELECTRON_RUN_AS_NODE=true electron as your node runtime". This is a very good solution, since using electron will both make the test environment closer to the execution environment and solve my specific issue with native modules.

I'd like to apply that, but I do no seem to be able to setup the jest CLI to use electron instead of node, and I have no idea where to start. Maybe I should run jest programmatically without the CLI ? But I might lose the nice test filtering features of the CLI.

Has anyone solved this already?



via Eric Burel

No comments:

Post a Comment