Add --require feature to ospec executable (#2144)

* Allow requires before running tests

This enables requiring modules like `esm` before any test files are loaded.

* Update ospec documentation

Also add documentation for `--require` option

* Update ospec change-log.md

* [opsec] move the change log item to v2.0

* [ospec] tweak the docs
This commit is contained in:
Gilbert 2018-05-09 10:46:55 -05:00 committed by Pierre-Yves Gérardy
parent 43053c6088
commit 91b08c6491
3 changed files with 42 additions and 18 deletions

View file

@ -27,6 +27,10 @@ const globList = args.globs && args.globs.length ? args.globs : ["**/tests/**/*.
const ignore = ["**/node_modules/**"].concat(args.ignore||[])
const cwd = process.cwd()
args.require && args.require.forEach(function(module) {
module && require(require.resolve(module, { basedir: cwd }))
})
let pending = globList.length
globList.forEach((globPattern) => {
glob(globPattern, {ignore})