feat: add testDefault spec attribute#249
Conversation
| ### testOnly | ||
|
|
||
| The `testOnly` helper function is available for setting a default value for an env var only when `NODE_ENV=test`. It is recommended to use this function along with `devDefault`. For example: | ||
| The `testOnly` helper function is available for setting a default value for an env var only when `NODE_ENV=test`. It is used by wrapping a `devDefault` value: |
There was a problem hiding this comment.
I think (after this PR) it probably makes sense to just remove the testOnly helper– can you think of any remaining use for it? It's always been a bit awkward
There was a problem hiding this comment.
Yes I don't see any remaining use cases for it. In fact I've been using envalid for more than 10 years (thanks for maintaining it!) and never used testOnly. I always wished there was a testDefault as my workflow is often to have no prod default but both dev & test defaults.
I would suggest to first release testDefault as a minor release and remove testOnly for the next major (I'm sure that's what you have in mind).
There was a problem hiding this comment.
Agreed, I just released v8.2.0, and v9 will follow in the next few days with testDefault removed and a few other small breaking changes
|
Nice PR, thank you! |
Add a
testDefaultspec attribute that takes priority whenNODE_ENV == "test", addressing #130.