-
Notifications
You must be signed in to change notification settings - Fork 844
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
Build targeting Jest with relevant transforms #2698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think
test-kbn
would make more sense astest-env
ortesting-env
- at this point should all build targets be moved to
dist
? e.g.dist/es
,dist/lib
, etc - needs documentation for using (creating testenv files) and consuming (using this build in another project) - once things are finalized, but wanted to include it here anyway
Changed to
I think yes, but I'd prefer to do that at a separate time. The number of import path updates that would be necessary in Kibana alone is very large.
For sure. I've updated the description checklist to make this a todo item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, one real ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more round, then let's move on to the next phase of this! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one more thought, but it shouldn't be blocking for getting additional feedback on this.
Pulled & built, verifying:
- existing
es
&lib
builds are not affected by the mocked icon - new
test-env
build is generated as expected, a commonjs build likelib
but has icon.testenv.jsx applied - eui.d.ts does not contain definitions from .testenv. files
testenv
build can be pulled into a JSDOM environment, with ReactDOM correctly rendering the mocked icon to the expected stringtestenv
directory is excluded from gitnpm pack
includes the newtest-env
target
@chandlerprall @spalger I've added documentation and think this can soon be merged. Having this available in an EUI release will help get the Kibana PR moving |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment, otherwise this is great!
Co-Authored-By: Chandler Prall <[email protected]>
Summary
Adds a third build target: commonjs via babel with async function and dynamic import transforms applied.
The goal is to eliminate needing to transform EUI from within Kibana's Jest setup, using
moduleNameMapper
to point to the targeted build in testing contexts. See the Draft PR for changes to be make to Kibana.Resolves #2065
This also proposes a pattern for overriding components ad hoc for the benefit of testing. See changes related to
icons.tsx
, in which the component is fully rewritten to avoid dynamic imports. Looking for opinions on what we should actually render when it comes to icon snapshots.Testing steps:
yarn build
from euinpm pack
and change Kibana'spackage.json
, or copy over a subset of directories to Kibananode_modules
yarn test:jest
from kibanaChecklist
- [ ] Check against all themes for compatability in both light and dark modes- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs*.testenv.*
files for testing purposes)- [ ] Checked for accessibility including keyboard-only and screenreader modes