javascript - Global variables for unit tests in SailsJS app -


i'm working on sails app, , unit tests, need use variable in ./test/bootstrap.test.js , in ./test/unit/controllers/*.test.js. think global variables, how can create them ?

i create ./config/mydatatest.js :

module.exports.myconf = {         anyobject: {       bar: "foo"     } }; 

but there way create mydatatest.js in test directory ?

i idea of considering test specific environment development or production. create environment-specific file config/env/test.js put configuration:

/**  * test environment settings  */ module.exports = {     myconf: {     anyobject: {       bar: "foo"     }   } }; 

then, add node_env=test command launch tests (based on the example documentation)

"scripts": {   "start": "node app.js",   "debug": "node debug app.js",   "test": "node_env=test mocha test/bootstrap.test.js test/unit/**/*.test.js" }, 

i use technique use sails-memory adapters when run tests.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -