使用Mocha进行测试并尝试使用babel并尝试使用array.prototype.includes

时间:2016-02-03 15:28:56

标签: mocha webpack babeljs

我正在使用Mocha测试我的react / redux代码并期望,我将mocha配置为使用es6,但它似乎缺乏对array.prototype.includes的支持,即使我有.babelrc指定stage-0。在我的非测试代码中,array.prototype.includes工作。除了特定于mocha的babelrc之外是否有一些设置需要设置才能使用array.prototype.includes?

这是我的package.json

{
  "name": "client",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha --compilers js:babel-core/register --recursive",
    "test:watch": "npm test -- --watch",
    "start": "node server.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.4.0",
    "babel-loader": "^6.2.1",
    "babel-polyfill": "^6.3.14",
    "babel-preset-es2015": "^6.3.13",
    "babel-preset-react": "^6.3.13",
    "babel-preset-stage-0": "^6.3.13",
    "expect": "^1.14.0",
    "lodash": "^4.0.1",
    "mocha": "^2.4.5",
    "react-addons-test-utils": "^0.14.7",
    "react-hot-loader": "^1.3.0",
    "redux-devtools": "^3.0.2",
    "redux-devtools-dock-monitor": "^1.0.1",
    "redux-devtools-log-monitor": "^1.0.2",
    "webpack": "^1.12.11",
    "webpack-dev-server": "^1.14.1"
  },
  "dependencies": {
    "axios": "^0.8.1",
    "cuid": "^1.3.8",
    "history": "^1.17.0",
    "lodash": "^4.0.1",
    "ramda": "^0.19.1",
    "react": "^0.14.6",
    "react-addons-shallow-compare": "^0.14.7",
    "react-dom": "^0.14.6",
    "react-redux": "^4.0.6",
    "react-router": "^1.0.3",
    "react-router-redux": "^2.1.0",
    "redux": "^3.1.7",
    "redux-crud": "^0.10.1",
    "redux-devtools": "^3.0.2",
    "redux-devtools-dock-monitor": "^1.0.1",
    "redux-devtools-log-monitor": "^1.0.2",
    "redux-loop": "^1.0.2",
    "redux-saga": "^0.4.1",
    "redux-simple-router": "^2.0.3",
    "reselect": "^2.0.3",
    "seamless-immutable": "^5.0.1"
  }
}

谢谢!

1 个答案:

答案 0 :(得分:0)

<div class="row" ng-model="rowHtml "> 是通过Array.prototype.includes提供的,因为它不需要转换。您的babel-polyfill似乎已经babel-polyfill了,所以请确保您在摩卡测试中package.json