Jest: Jest 16(实际上也是 Jest 15)没有正确地进行中继集成测试,但 Jest 14 正确地做到了

创建于 2016-10-08  ·  3评论  ·  资料来源: facebook/jest

您要请求一个 _feature_ 还是报告一个 _bug_?

一个错误。

目前的行为是什么?

故意失败的测试由 Jest 16 报告为通过。 Jest 14 正确地未通过测试。

这是 Jest 16 的输出(参见下方 Jest 14 的输出):

$ npm test

> @ test /Users/macbook/Documents/work/jest-relay-integration-test
> jest

 PASS  __tests__/Me-test-int.js
 PASS  __tests__/SignIn-test.js

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        9.316s
Ran all test suites.

如果当前的行为是一个错误,请提供重现的步骤,如果可能的话,我们可以在 GitHub 上提供一个最小的存储库,我们可以npm installnpm test

这是 repro 的 repo。

https://github.com/GrigoryPtashko/jest-relay-integration-test

主分支与 jest 16

jest14 分支与 jest 14

只需克隆它, npm install ,你就会自己看到一切。 使用分支在 Jest 版本之间切换。

什么是预期行为?

预期行为 - 再现中的测试必须失败。 因为它是一个失败的 Relay 集成测试。
这是 Jest 14 的正确输出:

$ npm test

> @ test /Users/macbook/Documents/work/jest-relay-integration-test
> jest

Using Jest CLI v14.1.0, jasmine2
 PASS  __tests__/SignIn-test.js (3.062s)
 FAIL  __tests__/Me-test-int.js (4.405s)
● Me › it can make request to /q anyway
  - Expected 'ROLE_ANONYMOUS' to equal 'ROLE_ANONYMOUS_AAA'.
        at AppRoot.render (__tests__/Me-test-int.js:39:61)
        at _combinedTickCallback (internal/process/next_tick.js:67:7)
        at process._tickCallback (internal/process/next_tick.js:98:9)
1 test failed, 1 test passed (2 total in 2 test suites, run time 6.087s)
npm ERR! Test failed.  See above for more details.

使用--debug再次运行 Jest 并提供它打印的完整配置。

$ npm --version
3.10.7
$ node --version
v6.3.0
$ ./node_modules/.bin/jest --debug
jest version = 16.0.1
test framework = jasmine2
config = {
  "scriptPreprocessor": "/Users/macbook/Documents/work/jest-relay-integration-test/jestPreprocessor.js",
  "moduleNameMapper": [
    [
      "^.+\\.(scss)$",
      "/Users/macbook/Documents/work/jest-relay-integration-test/src/styleMock.js"
    ]
  ],
  "rootDir": "/Users/macbook/Documents/work/jest-relay-integration-test",
  "name": "-Users-macbook-Documents-work-jest-relay-integration-test",
  "setupFiles": [],
  "testRunner": "/Users/macbook/Documents/work/jest-relay-integration-test/node_modules/jest-jasmine2/build/index.js",
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/var/folders/cs/dzn14j_s1ns7bqbtb5_3w72c0000gn/T/jest",
  "clearMocks": false,
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "globals": {},
  "haste": {
    "providesModuleNodeModules": []
  },
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "preprocessorIgnorePatterns": [
    "/node_modules/"
  ],
  "resetModules": false,
  "testEnvironment": "jest-environment-jsdom",
  "testPathDirs": [
    "/Users/macbook/Documents/work/jest-relay-integration-test"
  ],
  "testPathIgnorePatterns": [
    "/node_modules/"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "testURL": "about:blank",
  "timers": "real",
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "cache": true,
  "watchman": true,
  "testcheckOptions": {
    "times": 100,
    "maxSize": 200
  }
}
 PASS  __tests__/SignIn-test.js
 PASS  __tests__/Me-test-int.js

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        4.587s, estimated 5s
Ran all test suites.

最有用的评论

@cpojer你能看看这个吗? 真想从14更新到16,不知道怎么...

所有3条评论

@cpojer你能看看这个吗? 真想从14更新到16,不知道怎么...

我有一个最新 Jest 的工作版本: https :

在这个问题之后弄清楚: https :

对于未来的研究人员,这是我的 5 美分。 感谢@sibelius,我让它与最新的Jest ,这里是https://github.com/GrigoryPtashko/jest-relay-integration-test。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

kentor picture kentor  ·  3评论

excitement-engineer picture excitement-engineer  ·  3评论

Secretmapper picture Secretmapper  ·  3评论

stephenlautier picture stephenlautier  ·  3评论

mmcgahan picture mmcgahan  ·  3评论