【问题标题】:reactJs Jest:`jsdom 4.x onward only works on io.js, not Node.jsT:reactJs Jest:`jsdom 4.x 以后仅适用于 io.js,不适用于 Node.jsT:
【发布时间】:2015-11-13 20:48:00
【问题描述】:

package.json:

 {
   "name": "flux-pricing",
   "version": "0.0.1",
   "description": "Pricing component with flux",
   "main": "js/app.js",
   "dependencies": {
      "flux": "^2.0.0",
      "jest-cli": "^0.5.0",
      "jsdom": ">= 0.1.23 < 4.0.0",
      "react": "^0.12.0",
      "underscore": "^1.7.0"
   },
  "devDependencies": {
      "browserify": "~6.2.0",
      "envify": "~3.0.0",
      "react": "^0.12.0",
      "reactify": "^0.15",
      "watchify": "~2.1.0",
      "gulp": "~3.8.9",
      "gulp-browserify": "~0.5.0",
      "gulp-concat": "~2.4.1",
      "node-jsx": "~0.2.0",
      "express": "~4.0.0"
     },
     "scripts": {
        "start": "watchify -o js/bundle.js -v -d .",
        "build": "browserify . | uglifyjs -cm > js/bundle.min.js",
        "test": "jest"
    },
   "jest": {
     "rootDir": "./js"
   },
  "browserify": {
     "transform": [
         "reactify",
         "envify"
       ]
   }

}

在 npm install 之后,当我尝试做 npm test

s\jsdom\lib\jsdom.js:3 `jsdom 4.x 以后仅适用于 io.js,不适用于 Node.jsT:https://github.com/tmpvar ^ 意外令牌非法 如何解决这个问题?

【问题讨论】:

  • 你做过任何研究吗? 请注意,从我们的 4.0.0 版本开始,jsdom 不再适用于 Node.js™,而是需要 io.js。如果您使用 Node.js™,仍然欢迎您安装 3.x 系列版本。
  • @BenFortune 我在 package.json 文件中使用了 "jsdom": ">= 0.1.23
  • npm install --save jsdom@3.1.2
  • @BenFortune 它需要较低版本的 node 。我目前使用的是 0.12,而这个需要节点为 0.10。降级 Dom 似乎不是一个好的选择
  • 不需要,0.10最低要求,如果你不想降级 jsdom 是你的唯一选择使用 io.js。

标签: node.js reactjs jestjs


【解决方案1】:

我遇到了同样的问题。解决方案是改用 Jest 0.4。

这是来自 github 的问题。 https://github.com/facebook/jest/issues/469#issuecomment-133105627

我实际上必须降级到 Jest 0.3 和节点 10.x 才能让 Jest React 示例正常工作。这是参考 https://github.com/facebook/jest/issues/427

【讨论】:

    猜你喜欢
    • 2017-02-08
    • 2017-06-28
    • 1970-01-01
    • 2013-05-12
    • 2016-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多