Code Monkey home page Code Monkey logo

Comments (7)

af avatar af commented on May 31, 2024 3

I like your workaround, and can't really think of a better one to be honest.

The issue I see with adding testDefault is that devDefault currently applies to both NODE_ENV=development and NODE_ENV=test, so IMO it'd be confusing if devDefault and testDefault overlapped. Also I'm not sure if test-only env vars are common enough to justify adding the feature– personally devDefault has always been sufficient for me.

Maybe we could add your testOnly helper function to the lib as a compromise?

from envalid.

SimenB avatar SimenB commented on May 31, 2024

Interesting. Currently I manually pass args when calling envalid.cleanEnv. Is that not feasible?

from envalid.

novemberborn avatar novemberborn commented on May 31, 2024

I've written a testOnly() method:

function testOnly (testDefault) {
  return process.env.NODE_ENV === 'test'
     ? testDefault
     : undefined
}

Which lets me do:

APP_COGNITO_CLIENT_ID: validators.cognitoUserPoolClientId({devDefault: testOnly('stub+client+id')}),

Which is an OK workaround, but having a testDefault property would be tidier.

from envalid.

novemberborn avatar novemberborn commented on May 31, 2024

Fair enough.

You mean require('envalid').testOnly(value)?

from envalid.

af avatar af commented on May 31, 2024

Yep, that's exactly what I'm thinking

from envalid.

novemberborn avatar novemberborn commented on May 31, 2024

Cool, will keep this issue in mind. Have some other projects also hoping for my attention πŸ˜„

If anybody else wants to pick this up, feel free!

from envalid.

DenisVASI9 avatar DenisVASI9 commented on May 31, 2024

How to use different values for test and for production?
I have an .env file created and the value is always from it

from envalid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.