Closed obihill closed 4 years ago
Could you please try to remove the || process.env.NODE_ENV === "test"
part in your .babelrc.js
, and check if this issue still occur?
I removed it earlier when testing, but still get the same issue when running the following:
NODE_ENV=development jest
I only added it because jest uses test
.
It seems to be an issue with Babel, but I'm not familiar enough with it to know how to fix it. I don't use Babel so we can eliminate that I installed any duplicate plugins, but I don't know what jest, and add-ons, have done behind the scenes.
try TYPE=test jest
Generally speaking, you will run two jobs when doing E2E testing:
When using jest-puppeteer-istanbul
, you should only use babel-plugin-istanbul
when you running the first job.
In parcel-example-with-jest-puppeteer
, you can run yarn run dev
(or npx dev
) to do the job 1, and yarn run test
(or npx test
) for the job 2. By default, yarn run dev
will set NODE_ENV
as development
and yawrn run test
will set NODE_ENV
as test
. So in the babel configration file, babel-plugin-istanbul
will only be used when NODE_ENV
is development
I'm not really sure what TYPE=test
is supposed to change. I tried that and a few other things but I couldn't get it to work.
Everything is setup for Jest-puppeteer, and it works really well for tests via puppeteer, but I was looking for a way to do code coverage.
After some searching online I was able to find a workable solution using puppeteer-to-istanbul. This works directly with puppeteer so it was quite easy to setup. There is an extra step of using nyc to generate the coverage report, but I don't mind. I'll probably put it inside an npm script to make it a single command.
Thanks a lot for the effort and assistance with this. Your example helped me as I used your method with the click event handler to enable the functionality I needed.
Cheers.
Good to know you found a workable solution. Enjoy coding 😉.
Thanks for building this. I'm trying to use it to get code coverage via jest with puppeteer.
I'm having an issue when I run a test via jest CLI. Below is the full error log:
I'm not familiar with using Babel, but I followed your instructions for setting things up.
Here is my jest.config.json:
Here is my .babelrc.js:
I followed your parcel example [with jest-puppeteer].
Thanks for your assistance.