Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...