Files
jasmine/spec/core/jasmineNamespaceSpec.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

77 lines
2.1 KiB
JavaScript

describe('The jasmine namespace', function() {
it('includes all expected properties', function() {
const actualKeys = new Set(Object.keys(jasmineUnderTest));
// toEqual doesn't generate diffs for set comparisons. Check this way
// instead so we get readable failure output.
expect(setDifference(expectedKeys(), actualKeys)).toEqual(new Set());
});
it('does not include any unexpected properties', function() {
const actualKeys = new Set(Object.keys(jasmineUnderTest));
// toEqual doesn't generate diffs for set comparisons. Check this way
// instead so we get readable failure output.
expect(setDifference(actualKeys, expectedKeys())).toEqual(new Set());
});
function expectedKeys() {
// Does not include properties added by requireInterface(), since that isn't
// called by defineJasmineUnderTest.js/nodeDefineJasmineUnderTest.js.
const result = new Set([
'MAX_PRETTY_PRINT_ARRAY_LENGTH',
'MAX_PRETTY_PRINT_CHARS',
'MAX_PRETTY_PRINT_DEPTH',
'debugLog',
'getEnv',
'isSpy',
'ParallelReportDispatcher',
'spyOnGlobalErrorsAsync',
'Timer',
'version',
// Asymmetric equality testers
'allOf',
'any',
'anything',
'arrayContaining',
'arrayWithExactContents',
'empty',
'falsy',
'is',
'mapContaining',
'notEmpty',
'objectContaining',
'setContaining',
'stringContaining',
'stringMatching',
'truthy',
// Currently undocumented but used in browser boot files, so it's
// effectively public
'getGlobal'
]);
if (typeof window !== 'undefined') {
// jasmine-html.js
result.add('HtmlReporterV2');
result.add('HtmlReporterV2Urls');
result.add('QueryString');
}
return result;
}
// Can't use Set#difference yet because it isn't available in Node <22,
// Firefox <108, or Safari <17.
function setDifference(a, b) {
const result = new Set();
for (const v of a) {
if (!b.has(v)) {
result.add(v);
}
}
return result;
}
});