Give tests the ability to inject non-module scripts into the test page
This commit is contained in:
parent
7f1a3faa54
commit
10dd03a48c
@ -40,15 +40,22 @@ runTestsInChrome();
|
|||||||
// ----------------------
|
// ----------------------
|
||||||
|
|
||||||
function writeSpecRunner() {
|
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.`);
|
console.log(`ERROR: ${packageRoot} does not contain a "${SPEC_DIR}" folder.`);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scripts = settings.lib_files || [];
|
||||||
|
|
||||||
const specFilenames = fs
|
const specFilenames = fs
|
||||||
.readdirSync(path.join(packageRoot, SPEC_DIR))
|
.readdirSync(path.join(packageRoot, spec_dir))
|
||||||
.filter(fn => fn.endsWith('.spec.js'))
|
.filter(fn => fn.endsWith('.spec.js'))
|
||||||
.map(fn => path.join(SPEC_DIR, fn));
|
.map(fn => path.join(spec_dir, fn));
|
||||||
|
|
||||||
runnerText = `<!DOCTYPE html>
|
runnerText = `<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@ -64,9 +71,10 @@ function writeSpecRunner() {
|
|||||||
<script defer src="/${JASMINE_DIR}/boot.js"></script>
|
<script defer src="/${JASMINE_DIR}/boot.js"></script>
|
||||||
|
|
||||||
<!-- normally include source files here, but now we rely on ES6 test modules to load them. -->
|
<!-- normally include source files here, but now we rely on ES6 test modules to load them. -->
|
||||||
|
${scripts.map(s => `<script src="${s}"></script>`).join('\n\t ')}
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
${specFilenames.map(fn => `<script type="module" src="${fn}"></script>`).join('\n ')}
|
${specFilenames.map(fn => `<script type="module" src="${fn}"></script>`).join('\n\t ')}
|
||||||
</head><body></body>
|
</head><body></body>
|
||||||
</html>`;
|
</html>`;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user