New " create-react-app
"; yarn add semantic-ui-react
; new component with simply this code:
import React, { PureComponent } from "react";
import Dropdown from "semantic-ui-react/dist/es/modules/Dropdown/Dropdown";
class NavbarRightMenu extends PureComponent {
render() {
<Dropdown item trigger={myTrigger}>
<Dropdown.Menu>Something! Booom!</Dropdown.Menu>
</Dropdown>;
}
}
yarn test
everything ok!
Instead now I got this:
src\index.test.js
● Test suite failed to run
C:\Project\node_modules\semantic-ui-react\dist\es\modules\Dropdown\Dropdown.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _defineProperty from 'babel-runtime/helpers/defineProperty';
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
at Object.<anonymous> (src/components/common/navbar_components/NavbarRightMenu.js:3:17)
at Object.<anonymous> (src/components/common/NavbarCommon.js:6:24)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.05s
Ran all test suites related to changed files.
Watch Usage: Press w to show more.
0.76.0
https://codesandbox.io/s/736j2w2ol6
I don't know how to test on codesandbox.
将导入更改为:
import { Dropdown } from 'semantic-ui-react'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.