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

Allow passing cliOptions through normal jest config? #66

Open
tunnckoCore opened this issue Jun 16, 2019 · 8 comments
Open

Allow passing cliOptions through normal jest config? #66

tunnckoCore opened this issue Jun 16, 2019 · 8 comments

Comments

@tunnckoCore
Copy link

tunnckoCore commented Jun 16, 2019

Would you consider this or not? Currently, we require to have jest-runner-eslint config file (or field) which... isn't that good if you want to provide "zero config" experience, or near zero.

So here we'll have config.cliOptions || explorer.searchSync(config.rootDir);

Worth nothing.

I'll PR if you agree.

@ljharb
Copy link
Collaborator

ljharb commented Jun 16, 2019

See #58, #31, #10, but also jestjs/jest#4278 (comment)

@tunnckoCore
Copy link
Author

tunnckoCore commented Jun 17, 2019

Hey, thanks! :) Uh, that's both very sad and surprising... I've just seen that runners accept { testPath, config } and thought it's the "normal jest config".

Any suggestion where this can be started? I'm not familiar with the jest codebase.

@tunnckoCore
Copy link
Author

tunnckoCore commented Jun 17, 2019

Actually, there is a way. Hacky one of course. But for now, we can use it until it land official. And of course, we will see the validation warnings but they don't break the execution anyway.

config.haste[runner-name] (e.g. config.haste.jest-runner-eslint) because that's the only thing that doesn't fail. For some reason config[runner-name] doesn't work.

Why in config.haste? Glad you asked. You can actually put whatever name you want in your jest config file (module.exports = { foobar: 123 }), but it won't appear in the jest runner (e.g. { config }, the config.foobar won't exist), but haste appears, always.

@tunnckoCore
Copy link
Author

This is the smallest and only needed change which adds such support.

https://github.com/tunnckoCoreHQ/devest/commit/508688f2b8157bbc74b3415930b2a97bfeeb1db0

Want PR?

@ljharb
Copy link
Collaborator

ljharb commented Jun 17, 2019

I don't think adding a bunch of validation warnings, or relying on a hack, is worth it.

@tunnckoCore
Copy link
Author

It's optional anyway and allows you to build on top of Jest, and when you know what are you doing. It worths when you know what are you doing and why.

Also, it's not "a bunch", it's one warning. And all this is some temporary solution.

@raine
Copy link

raine commented Sep 5, 2023

How is one supposed to pass cliOptions with this thing without getting these validation warnings?

// jest-runner-eslint.config.js
module.exports = {
  runner: 'jest-runner-eslint',
  displayName: 'lint',
  cliOptions: {
    fix: true
  }
};
$ jest -c jest-runner-eslint.config.js
● Validation Warning:

  Unknown option "cliOptions" with value {"fix": true} was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Is there some another way?

@nsunga
Copy link

nsunga commented Oct 24, 2023

EDIT: I think I got it to work -- configuration done in package.json helped and also installing fresh node_modules

hey @raine 👋 did u ever figure out how cliOptions is injected into the jest configuration?

I might be misunderstanding the README -- and havent had much luck with cliOptions either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants