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
This commit is contained in:
Steve Gravrock
2026-02-15 13:41:19 -08:00
parent 03006080d4
commit f12f4395f0
127 changed files with 1336 additions and 1367 deletions

View File

@@ -173,10 +173,13 @@ describe('ExceptionFormatter', function() {
});
it('filters Jasmine stack frames in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile()
});
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
const result = subject.stack(error);
jasmine.debugLog('Original stack trace: ' + error.stack);
jasmine.debugLog('Filtered stack trace: ' + result);
@@ -196,15 +199,18 @@ describe('ExceptionFormatter', function() {
});
it('handles multiline error messages in this environment', function() {
const jasmineFile = (function() {
const trace = new privateUnderTest.StackTrace(new Error());
return trace.frames[2].file;
})();
expect(jasmineFile).toMatch(/\/jasmine.js$/);
const msg = 'an error\nwith two lines';
const error = new Error(msg);
if (error.stack.indexOf(msg) === -1) {
pending("Stack traces don't have messages in this environment");
}
const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile()
});
const subject = new privateUnderTest.ExceptionFormatter({ jasmineFile });
const result = subject.stack(error);
const lines = result.split('\n');
@@ -284,7 +290,7 @@ describe('ExceptionFormatter', function() {
it('ensures that stack traces do not include the message in this environment', function() {
const error = new Error('an error');
const subject = new privateUnderTest.ExceptionFormatter({
jasmineFile: jasmine.private.util.jasmineFile()
jasmineFile: "doesn't matter"
});
const result = subject.stack(error, { omitMessage: true });
expect(result).not.toContain('an error');