Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.5k views
in Technique[技术] by (71.8m points)

node.js - Node Config: How to prevent use of custom-environment-variables.json for Jest tests

I have a couple of Jest tests running in my NodeJS application that is configured to extract a dbConnString setting from config, using node-config.

I have a test.json file that specifies a dbConnString value (this is the one I expect the Jest tests to use). I also have a custom-environment-variables.json file that contains mappings of keys to environment variables that contain the actual connection strings to use for my dev environment.

What I'm finding is that the Jest tests are using the said environment variables mapped in custom-environment-variables.json. How can I force the Jest tests to use the dbConnString setting defined in test.json?

I have confirmed that in a test the process.env.NODE_ENV does return test.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...