rmwc: Button displayed as "Unknown" in Snapshot Tests
-
What RMWC Version are you using [major.minor.patch]: 5.1.8
-
Name your build system [Webpack, Rollup…]: create-react-app-ts
-
Describe the bug with as much detail as possible:
Error while executing a test:
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export default () => {
^^^^^^
SyntaxError: Unexpected token export
Code:
import * as React from 'react';
import { configure, shallow } from 'enzyme';
import * as ReactSixteenAdapter from 'enzyme-adapter-react-16';
// @ts-ignore -> somehow no typescript typings were found for this
import rmwcTestPolyfill from '@rmwc/base/test-polyfill';
configure( {adapter: new ReactSixteenAdapter()} );
rmwcTestPolyfill();
The test fails on the line configure. If I don’t include the call to rmwcTestPolyfill(); though, everything runs through. So I think this issue is with rmwc instead of enzyme.
If I don’t include the polyfill I get Unknown objects in the snapshots though. I hoped that the polyfill would fix that as documented in the Getting started guide. Example:
<Unknown
dense={true}
onClick={[Function]}
raised={true}
>
Text
</Unknown>
- What happened, and what was supposed to happen:
- An error occured while executing my tests.
- The test code should run through.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (10 by maintainers)
Commits related to this issue
- fix(Tests): corrects issue with ES6 export in polyfill #426 — committed to rmwc/rmwc by jamesmfriedman 5 years ago
Woot woot! Great to hear.
Which is precisely why this now exists 😃
https://jamesmfriedman.github.io/rmwc/resources
This could just be an issue with the displayName of the button. I can take a look at that.
Either way the other thing you’re encountering is also an issue, but rheee is no reason the polyfill should impact the display name of a component.