jest-runner-eslint
jest-runner-eslint copied to clipboard
Allow passing cliOptions through normal jest config?
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.
See #58, #31, #10, but also https://github.com/facebook/jest/issues/4278#issuecomment-326676409
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.
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.
This is the smallest and only needed change which adds such support.
https://github.com/tunnckoCoreHQ/devest/commit/508688f2b8157bbc74b3415930b2a97bfeeb1db0
Want PR?
I don't think adding a bunch of validation warnings, or relying on a hack, is worth it.
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.
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?
EDIT: I think I got it to work -- configuration done in package.json helped and also installing fresh node_modules
hey @raine :wave: 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