新" create-react-app
&#34 ;;
yarn add semantic-ui-react
;
只需使用此代码的新组件:
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
一切都好!
现在我得到了这个:
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
我不知道如何测试codeandbox。
答案 0 :(得分:0)
将导入更改为:
import { Dropdown } from 'semantic-ui-react'