Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v25] - [ ERROR ] runJest: TypeError: runCLI is not a function #9512

Closed
peterennis opened this issue Feb 3, 2020 · 2 comments
Closed

[v25] - [ ERROR ] runJest: TypeError: runCLI is not a function #9512

peterennis opened this issue Feb 3, 2020 · 2 comments

Comments

@peterennis
Copy link

🐛 Bug Report

[ ERROR ] runJest: TypeError: runCLI is not a function

To Reproduce

Steps to reproduce the behavior:

Repo: https://github.com/adaept/ae-icon5-component

C:\ae\adaept.com\_components_\ae-icon5-component>npm test

> @adaept/[email protected] test C:\ae\adaept.com\_components_\ae-icon5-component
> stencil test --spec --e2e

[14:29.4]  @stencil/core v1.9.0-14
[14:29.4]  testing e2e and spec files
[14:29.4]  build, aeicon5component, dev mode, started ...
[14:30.9]  transpile started ...
[14:31.4]  transpile finished in 514 ms
[14:31.7]  copy started ...
[14:32.3]  generate styles started ...
[14:32.3]  bundling components started ...
[14:32.4]  generate styles finished in 146 ms
[14:34.6]  bundling components finished in 2.31 s
[14:38.8]  copy finished (2462 files) in 7.05 s
[14:38.8]  build finished in 9.40 s

[14:39.0]  jest args: --e2e --spec --max-workers=4

[ ERROR ]  runJest: TypeError: runCLI is not a function


npm ERR! Test failed.  See above for more details.

C:\ae\adaept.com\_components_\ae-icon5-component>

Downgrade to 24.9 shows this result:

C:\ae\adaept.com\_components_\ae-icon5-component>npm test

> @adaept/[email protected] test C:\ae\adaept.com\_components_\ae-icon5-component
> stencil test --spec --e2e

[20:34.8]  @stencil/core v1.9.0-14
[20:34.9]  testing e2e and spec files
[20:34.9]  build, aeicon5component, dev mode, started ...
[20:35.7]  transpile started ...
[20:36.5]  transpile finished in 848 ms
[20:36.9]  copy started ...
[20:37.4]  generate styles started ...
[20:37.4]  bundling components started ...
[20:37.7]  generate styles finished in 326 ms
[20:40.0]  bundling components finished in 2.57 s
[20:40.6]  copy finished (2462 files) in 3.72 s
[20:40.8]  build finished in 5.92 s

[20:40.9]  jest args: --e2e --spec --max-workers=4
 FAIL  src/components/ae-icon5-component/ae-icon5-component.spec.ts
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/@jest/core/build/TestScheduler.js:242:24
      at asyncGeneratorStep (node_modules/@jest/core/build/TestScheduler.js:131:24)
      at _next (node_modules/@jest/core/build/TestScheduler.js:151:9)
      at node_modules/@jest/core/build/TestScheduler.js:156:7
      at node_modules/@jest/core/build/TestScheduler.js:148:12
      at onResult (node_modules/@jest/core/build/TestScheduler.js:271:25)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.48s
Ran all test suites.

npm ERR! Test failed.  See above for more details.

C:\ae\adaept.com\_components_\ae-icon5-component>

The component has an empty spec test file so the report from
jest 24.9 is correct.

The error message from jest 25 is inaccurate and misleading.

Ref: ionic-team/stencil#2168

Expected behavior

Better error report that matches the situation.

Link to repl or repo (highly encouraged)

envinfo

24.9

C:\ae\adaept.com\_components_\ae-icon5-component>npx envinfo --preset jest
npx: installed 1 in 10.129s

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: 24.9.0 => 24.9.0

25

C:\ae\adaept.com\_components_\ae-icon5-component>npx envinfo --preset jest
npx: installed 1 in 3.091s

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i7-3540M CPU @ 3.00GHz
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: 25.1.0 => 25.1.0
@SimenB
Copy link
Member

SimenB commented Feb 4, 2020

This is due to how stencil import runCLI here: https://github.com/ionic-team/stencil/blob/45821831683d0a468b1e38a3179b4c03c2acba7a/src/testing/jest/jest-runner.ts#L31. This was changed in #8874 (comment)

They can change their import from const { runCLI } = require('jest-cli'); to const { runCLI } = require('@jest/core');. That package started shipping in 24.3.0, so it should probably be a fallback if runCLI is not found from jest-cli package to support all releases of Jest 24. Can also do const { runCLI } = require('jest'). The programmatic API is pretty bad, tracked in #5048

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants