Jest: Improve and separate validation from normalisation in jest-config

Created on 4 Jan 2017  Â·  6Comments  Â·  Source: facebook/jest

Do you want to request a feature or report a bug?

Feature / Refactor

What is the current behavior?

This came up while working on #2494 and #2228.
In jest-config some options are validated in normalize.js and some are not. This results in many really lousy error messages when something is not right with the configuration.

What is the plan?

  • Separate concerns of normalising and validating config
  • Add proper validation messages for _all_ config options
Enhancement UX

Most helpful comment

wow this is beautiful. Can we extract this into a separate package so that other tools can use this for better errors? I want this everywhere.

Nit: "Option haste must be of type:"

Instead of "Valid example" I recommend just "Example" – I would assume the example is always valid.

All 6 comments

I've seen this as well, I think the main problem is that the CLI options are overwriting whatever is already normalized because they run after normalization, while the correct beaviour would be:

Parse configuration
Parse CLI (so CLI always override default config)
Normalize

How do you like them brand new config errors

screen shot 2017-01-06 at 18 38 41

and warnings?

screen shot 2017-01-06 at 18 38 50

wow this is beautiful. Can we extract this into a separate package so that other tools can use this for better errors? I want this everywhere.

Nit: "Option haste must be of type:"

Instead of "Valid example" I recommend just "Example" – I would assume the example is always valid.

Sure, I'd like to expose it as jest-config-validate, but first of all I want to get it working properly with Jest alone.

How about jest-validate?

Moving the discussion to related PR

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephenlautier picture stephenlautier  Â·  3Comments

ianp picture ianp  Â·  3Comments

samzhang111 picture samzhang111  Â·  3Comments

kentor picture kentor  Â·  3Comments

Antho2407 picture Antho2407  Â·  3Comments