mardi 11 juillet 2017

How to use Node.js global variable in mocha tests

I have got a problem with mocha tests around global object I'm using with Node.js.

In index file, I set value to global variable

// index.js
global.enums = enumTemp

export default app

And then used it in another file

// other.js

status = global.enums.object.status

It's REST API and runs well if I made a request to a server. However, when I used Mocha test, it seems to be can not get value for Node.js global variable. Any idea everyone?

Aucun commentaire:

Enregistrer un commentaire