Nicola Della Morte
Nicola Della Morte

Reputation: 34

How can I test a constant value with mocha, chai, sinon?

to everyone, that's my first time here so I hope to do all in the right way. So, I'm writing unit tests for my app and nyc tell me that I have a file that is not 100% tested, that's a simple file to set the environment to load, and I don't know how can i test it. The file is the following:

const env = ["dev", "stag", "prod"].includes(Process.env?.MODE)? Process.env.MODE: "dev"

module.exports = require(`../config/.${env}.js`);

I suppose that I have to test the includes but I don't know how I can do it.

I have tried to use Array.prototype and includes with the sinon.stub but of course I don't know how to "call" the file. Maybe I have to use spy but I never use it and I didn't find someone with my same problem, so I suppose that's a stupid question but i want to solve it

Upvotes: 1

Views: 359

Answers (0)

Related Questions