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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import default Jest CLI options #11555

Closed
dyatko opened this issue Jun 10, 2021 · 6 comments
Closed

Cannot import default Jest CLI options #11555

dyatko opened this issue Jun 10, 2021 · 6 comments

Comments

@dyatko
Copy link

dyatko commented Jun 10, 2021

馃挜 Regression Report

We have an internal developer tooling, which extends jest-cli for our needs by adding few special CLI options.
In order to support all default Jest CLI options, we import them from jest-cli/build/cli/args.

Since Jest v27, the package exports were limited and we're not able to upgrade:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './build/cli/args' is not defined by "exports"

Last working version

Worked up to version: 26

Stopped working in version: 27

To Reproduce

Steps to reproduce the behavior:

import {options} from 'jest-cli/build/cli/args';

console.log(options);

Expected behavior

To see the options

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 14.15.1 - ~/.nvm/versions/node/v14.15.1/bin/node
    Yarn: 1.22.10 - ~/Dev/pacman/node_modules/.bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.1/bin/npm
@sforner405
Copy link

Is there a workaround?

@adamma1024
Copy link

adamma1024 commented Feb 21, 2022

Look at the code as follow:
https://github.com/facebook/jest/blob/67c1aa20c5fec31366d733e901fee2b981cb1850/packages/jest-cli/package.json#L7-L14

I have a similar question for:

import { buildArgv } from 'jest-cli/build/cli/index';
import init from 'jest-cli/build/init';

Since v27, jest-cli didn't export the build folder anymore. I can understand that this way may be "better" for modules. But I still think that it's a breaking change. Cause I can import them before(v26), and I can't import them now(v27). And v27 didn't supply some "remedies".

@SimenB

@adamma1024
Copy link

Btw, the NodeEnvironment class removed the runScript function, and I didn't find it ChangeLog too.

@SimenB
Copy link
Member

SimenB commented Feb 21, 2022

This is not a regression, you used unsupported and undocumented APIs.

Please open new a feature request asking for what it is you need. Just "I did this, please enable it" is an example of https://xyproblem.info/. Please describe what you want to do, not how you want to do it.

Also note that Jest does not really have a supported programmatic API (tracked in #5048), but minor changes to enable workarounds are always possible.


But I still think that it's a breaking change. Cause I can import them before(v26), and I can't import them now(v27).

Breaking changes are literally the point of major releases, not sure what your point is.

https://github.com/facebook/jest/blob/7a05a6c9de73791e40f1c60405913cbc5897b417/CHANGELOG.md?plain=1#L492

Btw, the NodeEnvironment class removed the runScript function, and I didn't find it ChangeLog too.

https://github.com/facebook/jest/blob/7a05a6c9de73791e40f1c60405913cbc5897b417/CHANGELOG.md?plain=1#L455

@SimenB SimenB closed this as completed Feb 21, 2022
@adamma1024
Copy link

Thanks for your response. It's a totally xyproblem, lol. And sorry for my carelessness, I'll open a feature issue to report my requirements.

@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 Mar 25, 2022
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

4 participants