diff --git a/bin/runTests.js b/bin/runTests.js index 5f36aa3..c140eea 100755 --- a/bin/runTests.js +++ b/bin/runTests.js @@ -40,15 +40,22 @@ runTestsInChrome(); // ---------------------- function writeSpecRunner() { - if (items.indexOf(SPEC_DIR) === -1) { + let settings = {}; + try { + settings = JSON.parse(fs.readFileSync(path.join(packageRoot, 'test.json'), 'utf8')); + } catch (e) {} + const spec_dir = settings.spec_dir || SPEC_DIR; + if (items.indexOf(spec_dir) === -1) { console.log(`ERROR: ${packageRoot} does not contain a "${SPEC_DIR}" folder.`); process.exit(-1); } + const scripts = settings.lib_files || []; + const specFilenames = fs - .readdirSync(path.join(packageRoot, SPEC_DIR)) + .readdirSync(path.join(packageRoot, spec_dir)) .filter(fn => fn.endsWith('.spec.js')) - .map(fn => path.join(SPEC_DIR, fn)); + .map(fn => path.join(spec_dir, fn)); runnerText = ` @@ -64,9 +71,10 @@ function writeSpecRunner() { + ${scripts.map(s => ``).join('\n\t ')} - ${specFilenames.map(fn => ``).join('\n ')} + ${specFilenames.map(fn => ``).join('\n\t ')} `;