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
Post a Comment