Files
jasmine/src/boot/jasmine-core.js
Steve Gravrock f12f4395f0 Redesigned moudule system
* 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
2026-02-15 20:16:45 -08:00

70 lines
1.6 KiB
JavaScript

'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')
}
};