Build targeting Jest with relevant transforms#2698
Build targeting Jest with relevant transforms#2698thompsongl merged 24 commits intoelastic:masterfrom
Conversation
chandlerprall
left a comment
There was a problem hiding this comment.
- I think
test-kbnwould make more sense astest-envortesting-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. |
chandlerprall
left a comment
There was a problem hiding this comment.
One nit, one real ask.
chandlerprall
left a comment
There was a problem hiding this comment.
One more round, then let's move on to the next phase of this! :)
There was a problem hiding this comment.
Left one more thought, but it shouldn't be blocking for getting additional feedback on this.
Pulled & built, verifying:
- existing
es&libbuilds are not affected by the mocked icon - new
test-envbuild is generated as expected, a commonjs build likelibbut has icon.testenv.jsx applied - eui.d.ts does not contain definitions from .testenv. files
testenvbuild can be pulled into a JSDOM environment, with ReactDOM correctly rendering the mocked icon to the expected stringtestenvdirectory is excluded from gitnpm packincludes the newtest-envtarget
|
@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 |
chandlerprall
left a comment
There was a problem hiding this comment.
One comment, otherwise this is great!
Co-Authored-By: Chandler Prall <chandler.prall@gmail.com>
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
moduleNameMapperto 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 buildfrom euinpm packand change Kibana'spackage.json, or copy over a subset of directories to Kibananode_modulesyarn test:jestfrom 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