zoukankan      html  css  js  c++  java
  • react config test env with jest and create-react-app 1

    /.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() });
  • 相关阅读:
    博客园如何运行代码
    视觉差
    h5 播放器 -3
    播放器 视频 音频 -1
    游戏 保卫萝卜
    跟踪算法
    走口字

    联动日历
    jq 抽奖
  • 原文地址:https://www.cnblogs.com/or2-/p/9870229.html
Copyright © 2011-2022 走看看