react config test env with jest and create-react-app 1
发布时间:2020-12-15 20:21:28 所属栏目:百科 来源:网络整理
导读:/.babelrc 1 { 2 " presets " : [ " @babel/preset-env " , " @babel/preset-react " ], 3 " plugins " :[ 4 " @babel/plugin-proposal-class-properties " 5 ] 6 } /jest.config.js 1 module.exports = { 2 3 4 " setupFiles " : [ " ./tests/setup.js " ],
/.babelrc 1 { 2 "presets": ["@babel/preset-env","@babel/preset-react"],3 "plugins":[ 4 "@babel/plugin-proposal-class-properties" 5 ] 6 } /jest.config.js 1 module.exports = { 2 3 4 "setupFiles": ["./tests/setup.js"],5 6 testEnvironment: "node",7 8 9 }; /package.json 1 "devDependencies": { 2 "babel-core": "7.0.0-bridge.0", 3 "@babel/core": "^7.1.2", 4 "@babel/preset-env": "^7.1.0", 5 "@babel/preset-react": "^7.0.0", 6 "@babel/plugin-proposal-class-properties": "^7.1.0", 7 "@babel/plugin-proposal-object-rest-spread": "^7.0.0", 8 "babel-jest": "^23.6.0", 9 "enzyme": "/home/rudy/.config/yarn/global/node_modules/enzyme",10 "enzyme-adapter-react-16": "/home/rudy/.config/yarn/global/node_modules/enzyme-adapter-react-16",11 "jest": "^23.6.0" 12 },13 "scripts": { 14 "start": "react-scripts start",15 "build": "react-scripts build",16 "test": "jest",17 "eject": "react-scripts eject" 18 }, /tests/setup.js 1 import { configure } from ‘enzyme‘; 2 import Adapter from ‘enzyme-adapter-react-16‘; 3 configure({ adapter: new Adapter() }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |