* Top level private APIs (e.g. jasmine.private.whatever) are no longer exposed * jasmineRequire is no longer exposed * core is self-booting * Globals are automatically created in browsers. (They can subsequently be removed by user code if desired.) * Globals are *not* automatically created in Node. An installGlobals function is exported instead. The jasmine package calls installGlobals unless configured not to do so. * In Node, the same instance is returned each time jasmine-core is imported. A reset function is exported. It effectively resets all state by discarding the env and creating a new one. This allows mulitple sequential runs within the same process to be independent of each other, but does not allow multiple concurrent runs. (That probably never worked anyway.) Fixes #2094
94 lines
2.7 KiB
JavaScript
94 lines
2.7 KiB
JavaScript
/*
|
|
Copyright (c) 2008-2019 Pivotal Labs
|
|
Copyright (c) 2008-2026 The Jasmine developers
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
a copy of this software and associated documentation files (the
|
|
"Software"), to deal in the Software without restriction, including
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const {
|
|
globals,
|
|
installGlobals,
|
|
private$
|
|
} = require('./jasmine-core/jasmine.js');
|
|
|
|
function reset() {
|
|
private$.currentEnv_ = null;
|
|
const env = jasmine.getEnv({ suppressLoadErrors: true });
|
|
rebindInterface(env);
|
|
}
|
|
|
|
const rootPath = path.join(__dirname, 'jasmine-core'),
|
|
bootFiles = ['boot.js'],
|
|
cssFiles = [],
|
|
jsFiles = [],
|
|
jsFilesToSkip = ['jasmine.js'].concat(bootFiles);
|
|
|
|
fs.readdirSync(rootPath).forEach(function(file) {
|
|
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
|
switch (path.extname(file)) {
|
|
case '.css':
|
|
cssFiles.push(file);
|
|
break;
|
|
case '.js':
|
|
if (jsFilesToSkip.indexOf(file) < 0) {
|
|
jsFiles.push(file);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Note: Only available on Node.
|
|
*
|
|
* In addition to the members documented here, this module's exports include all
|
|
* {@link globals}.
|
|
* @module jasmine-core
|
|
*/
|
|
module.exports = {
|
|
...globals,
|
|
/**
|
|
* Copies Jasmine globals (jasmine, describe, it, etc) to the specified
|
|
* object or to globalThis.
|
|
* @function
|
|
* @param {object} [dest] - The object to copy globals to.
|
|
*/
|
|
installGlobals,
|
|
/**
|
|
* Resets all of jasmine-core's state, including removing specs, suites, and
|
|
* reporters, and resetting configuration to the default.
|
|
* @function
|
|
*/
|
|
reset,
|
|
files: {
|
|
self: __filename,
|
|
path: rootPath,
|
|
bootDir: rootPath,
|
|
bootFiles: bootFiles,
|
|
cssFiles: cssFiles,
|
|
jsFiles: ['jasmine.js'].concat(jsFiles),
|
|
imagesDir: path.join(__dirname, '../images')
|
|
}
|
|
};
|