jsdoc/test/index.js
Jeff Williams 5f578e803b migrate from old, vendored Jasmine to jasmine package (#1602)
Plus some miscellaneous cleanup.
2019-01-21 19:38:07 -08:00

40 lines
1.1 KiB
JavaScript

const env = require('jsdoc/env');
const Jasmine = require('jasmine');
const klawSync = require('klaw-sync');
const path = require('path');
const SCHEMA_SPEC = path.resolve('test/specs/jsdoc/schema.js');
const SPEC_FILES = (() => {
// Normal specs are specs that don't need filtering.
const normalSpecs = [
'packages/**/test/specs/**/*.js',
'plugins/test/specs/**/*.js'
];
// Klawed specs are specs we've filtered to avoid the schema spec, which must run last.
const klawedSpecs = klawSync('test/specs', {
filter: (item) => (item.path !== SCHEMA_SPEC),
nodir: true
}).map((item) => item.path);
// We want an array of spec files with the schema spec at the end.
return normalSpecs.concat(klawedSpecs).concat([SCHEMA_SPEC]);
})();
module.exports = () => {
const jasmine = new Jasmine();
const matcher = env.opts.matcher;
const promise = new Promise(() => {});
jasmine.loadConfig({
helpers: [
'test/helpers/**/*.js'
],
random: false
});
jasmine.onComplete(() => promise.resolve());
jasmine.execute(SPEC_FILES, matcher);
return promise;
};