所有测试都通过 100% 覆盖率,但 jest 返回退出代码 1

Tho*_*ggi 6 jestjs

我研究过--detectLeaks--detectOpenHandles,它确实引发了一些错误,但输出中没有明显的问题。

\n\n

我有一个 monorepo,我正在 docker/管道中的 jenkins 中运行 jest。

\n\n
> abide@1.0.0 jest /var/jenkins_home/workspace/abide\n> jest --coverage --no-cache --runInBand\n\n[BABEL] Note: The code generator has deoptimised the styling of "/var/jenkins_home/workspace/abide/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".\nPASS packages/help.parse-argv/index.test.js (10.842s)\n[BABEL] Note: The code generator has deoptimised the styling of "/var/jenkins_home/workspace/abide/node_modules/text-encoding/lib/encoding-indexes.js" as it exceeds the max of "500KB".\nhello\nnpm notice created a lockfile as package-lock.json. You should commit this file.\n+ example-working@0.0.1\nadded 2 packages from 2 contributors and audited 2 packages in 2.837s\nfound 0 vulnerabilities\n\nrequire successfull\nUsage: --function <args> [--function <args>]\n\n    --a (echo hi)\n    --b (echo hi)\n    --c (echo hi)\n    --help (shows this help output)\n--------------------------------|----------|----------|----------|----------|-------------------|\nFile                            |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |\n--------------------------------|----------|----------|----------|----------|-------------------|\nAll files                       |      100 |      100 |      100 |      100 |                   |\n command                        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n command-plus                   |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n dep-merge                      |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n dep-merge-cli                  |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n dep-pointer                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n dep-pointer-cli                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n gitpkg.traverse-up             |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n gitpkg.upsert                  |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n help                           |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n help.filter-until              |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n help.parse-argv                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n help.set-entire                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n help.string-argv               |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n here                           |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey                        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey.coerce-to-array        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey.coerce-to-plain-object |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey.fn-free                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey.fn-reduce              |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n journey.pass-thru              |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n lerna.paths                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n lerna.utils                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n monorepo-babel-cli             |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n monorepo-dep-lint-cli          |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg                            |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-cli                        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-babel-6-to-node-4   |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-babel-7-to-node-4   |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-cobalt              |        0 |        0 |        0 |        0 |                   |\n  index.js                      |        0 |        0 |        0 |        0 |                   |\n pkg-plugin-jest                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-name-dir            |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-name-scope          |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-prop                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-sort                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg-plugin-standard            |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.file-exists                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.fs                         |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.is-local-module            |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.json-parse                 |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.pretty-json                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.prop-overwrite             |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.read-json                  |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkg.throw-error                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkgprop                        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n pkgprop-cli                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n reggi-cli                      |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n replace-cli                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n requireable                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n requireable-cli                |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n results-cli                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n shebang-check                  |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n shebang-check-cli              |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n subrepo                        |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n subrepo-cli                    |      100 |      100 |      100 |      100 |                   |\n  index.js                      |      100 |      100 |      100 |      100 |                   |\n--------------------------------|----------|----------|----------|----------|-------------------|\nnpm ERR! code ELIFECYCLE\nnpm ERR! errno 1\nnpm ERR! abide@1.0.0 jest: `jest --coverage --no-cache --runInBand`\nnpm ERR! Exit status 1\nnpm ERR! \nnpm ERR! Failed at the abide@1.0.0 jest script.\nnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR!     /root/.npm/_logs/2018-06-20T13_11_31_412Z-debug.log\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的笑话配置:

\n\n
{\n    "collectCoverage": true,\n    "coveragePathIgnorePatterns": [\n      "<rootDir>/unpublished/.+",\n      "<rootDir>/packages/.+/examples/.+",\n      ".+build.js",\n      "<rootDir>packages/pkg-plugin-prop/index.build.js"\n    ],\n    "coverageReporters": [\n      "html",\n      "text"\n    ],\n    "coverageThreshold": {\n      "global": {\n        "branches": 100,\n        "functions": 100,\n        "lines": 100,\n        "statements": 100\n      }\n    },\n    "modulePathIgnorePatterns": [\n      "<rootDir>/unpublished/.+",\n      "<rootDir>/packages/.+/examples/.+",\n      ".+build.js"\n    ],\n    "projects": [\n      "<rootDir>/packages/.+"\n    ],\n    "testPathIgnorePatterns": [\n      "<rootDir>/unpublished/.+",\n      "<rootDir>/packages/.+/examples/.+",\n      ".+build.js"\n    ],\n    "watchPathIgnorePatterns": [\n      "<rootDir>/unpublished/.+",\n      "<rootDir>/packages/.+/examples/.+",\n      ".+build.js"\n    ]\n  }\n
Run Code Online (Sandbox Code Playgroud)\n\n

这里发生了什么?

\n\n

在本地,它确实返回 0 退出代码并打印:

\n\n
Snapshot Summary\n \xe2\x80\xba 11 snapshots written from 6 test suites.\n\nTest Suites: 55 passed, 55 total\nTests:       290 passed, 290 total\nSnapshots:   11 written, 12 passed, 23 total\nTime:        112.189s\nRan all test suites.\n\n> abide@1.0.0 postjest /Users/thomas/Desktop/github.com/reggi/abide\n> here --cleanCoverage\n
Run Code Online (Sandbox Code Playgroud)\n

Tho*_*ggi 0

我有一个模块正在调用process.stderr.write()

我使用 lerna 单独运行每个程序来找到它。

lerna exec --concurrency 1 -- jest --no-cache --runInBand --ci
Run Code Online (Sandbox Code Playgroud)