Add experimental safariYieldStrategy: "time" config option

This greatly improves speed, at least in jasmine-core's own tests.
This commit is contained in:
Steve Gravrock
2025-11-12 21:08:59 -08:00
parent 7b2807b321
commit 9c2ffae2f9
7 changed files with 224 additions and 36 deletions

View File

@@ -15,7 +15,8 @@ describe('Configuration', function() {
'seed',
'specFilter',
'extraItStackFrames',
'extraDescribeStackFrames'
'extraDescribeStackFrames',
'safariYieldStrategy'
];
Object.freeze(standardBooleanKeys);
Object.freeze(allKeys);
@@ -36,6 +37,7 @@ describe('Configuration', function() {
expect(subject.detectLateRejectionHandling).toEqual(false);
expect(subject.extraItStackFrames).toEqual(0);
expect(subject.extraDescribeStackFrames).toEqual(0);
expect(subject.safariYieldStrategy).toEqual('count');
});
describe('copy()', function() {
@@ -137,5 +139,28 @@ describe('Configuration', function() {
subject.update({ extraDescribeStackFrames: 100000 });
expect(subject.extraDescribeStackFrames).toEqual(100000);
});
it('sets safariYieldStrategy when valid', function() {
const subject = new privateUnderTest.Configuration();
subject.update({ safariYieldStrategy: undefined });
expect(subject.safariYieldStrategy).toEqual('count');
subject.update({ safariYieldStrategy: 'time' });
expect(subject.safariYieldStrategy).toEqual('time');
subject.update({ safariYieldStrategy: 'count' });
expect(subject.safariYieldStrategy).toEqual('count');
});
it('rejcts invalid safariYieldStrategy values', function() {
const subject = new privateUnderTest.Configuration();
expect(function() {
subject.update({ safariYieldStrategy: 'thyme' });
}).toThrowError(
"Invalid safariYieldStrategy value. Valid values are 'count' and 'time'."
);
});
});
});