react-browser-extension-boilerplate icon indicating copy to clipboard operation
react-browser-extension-boilerplate copied to clipboard

Add test configuration using Jest and RTL

Open LucasAndrad opened this issue 4 years ago • 4 comments

I really liked this boilerplate, so I would to add some contribution if you agree. Here is my idea about tests:

Having a test configuration will allow us developers to build more consistent and "security" extensions with this boilerplate.

  • [x] Add jest and RTL packages
  • [x] Add config on package.json and also the scripts to run tests
  • [ ] Add coverage command and report
  • [ ] Add tests description on README

I'm already working on this one, just need to fix a little problem with the coverage report, but let me know what you think about this please. Thank you.

LucasAndrad avatar May 24 '20 18:05 LucasAndrad

@LucasAndrad Yeah, we definitely need some tests.

I like RTL. But I'm not sure if we can somehow mock browser API.

I need to perform some research.)

ElForastero avatar May 25 '20 05:05 ElForastero

Good point, I didn't thought about it. I'll comment here if I find a solution for that.

LucasAndrad avatar May 25 '20 14:05 LucasAndrad

Hey @ElForastero, there is a package to mock browser api, and works just fine: https://github.com/clarkbw/jest-webextension-mock

I'm facing some problems with @testing/preact. Is there an specific reason to use preact instead react? Just asking because I was able to test everything on my project after added react on it.

Also if you want to take a look, here is what I did so far: https://github.com/LucasAndrad/react-browser-extension-boilerplate/tree/add-test-setup

LucasAndrad avatar Jun 07 '20 20:06 LucasAndrad

@LucasAndrad Great work 👍

I think we can switch the defaults from Preact to React.

Using Preact can really lead to some strange problems, and would be better to leave this at the discretion of the user.

ElForastero avatar Jun 08 '20 03:06 ElForastero