-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add option to test native shadow DOM #122
Conversation
I am a little concerned with creating yet another configuration file for LWC. We already have today the Here are a couple of other alternatives worth considering IMO:
|
I'm happy to go with the |
OK, switched to using Jest |
Co-authored-by: Pierre-Marie Dartus <p.dartus@salesforce.com>
Co-authored-by: Eugene Kashida <ekashida@gmail.com>
Adds a way to test native shadow DOM in
@lwc/jest-preset
. (I guess it's "native" because it's implemented by Jest/JSDOM. 🙂 ). Fixes #93.Options file
To add this option, I had to add a config file,
lwc-jest.config.js
. It can contain:Why
lwc-jest.config.js
? Well, I looked at a few Jest presets mentioned on the Jest website. Here's what they're doing:jest-mongodb-config.js
jest-dynamodb-config.js
jest-puppeteer.config.js
I think
lwc-jest.config.js
looks better thanlwc-jest-config.js
(especially next tojest.config.js
), so I went withjest-puppeteer
's format. 🙂Testing
In our tests, I'd like to confirm that we're actually reading the config file and running in the right shadow mode. The most straightforward way I found is to run the full test suite in both synthetic and shadow mode using
process.env.NATIVE_SHADOW
to switch.This has the benefit of ensuring our tests don't break in either mode. I can also confirm that both modes are working correctly by sniffing
ShadowRoot.prototype.constructor.toString()
.Gus WI
W-9318249