Skip to content

Commit 8b888dc

Browse files
committed
Gate tests to source
1 parent 5ea434b commit 8b888dc

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

packages/scheduler/src/__tests__/SchedulerPostTaskOnly-test.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,28 @@ let NormalPriority;
2121

2222
describe('SchedulerPostTaskOnly', () => {
2323
beforeEach(() => {
24-
jest.resetModules();
25-
26-
// Un-mock scheduler
27-
jest.mock('scheduler', () =>
28-
require.requireActual('scheduler/unstable_post_task_only'),
29-
);
30-
31-
runtime = installMockBrowserRuntime();
32-
performance = window.performance;
33-
Scheduler = require('scheduler');
34-
cancelCallback = Scheduler.unstable_cancelCallback;
35-
scheduleCallback = Scheduler.unstable_scheduleCallback;
36-
NormalPriority = Scheduler.unstable_NormalPriority;
24+
if (!process.env.IS_BUILD) {
25+
jest.resetModules();
26+
27+
// Un-mock scheduler
28+
jest.mock('scheduler', () =>
29+
require.requireActual('scheduler/unstable_post_task_only'),
30+
);
31+
32+
runtime = installMockBrowserRuntime();
33+
performance = window.performance;
34+
Scheduler = require('scheduler');
35+
cancelCallback = Scheduler.unstable_cancelCallback;
36+
scheduleCallback = Scheduler.unstable_scheduleCallback;
37+
NormalPriority = Scheduler.unstable_NormalPriority;
38+
}
3739
});
3840

3941
afterEach(() => {
40-
if (!runtime.isLogEmpty()) {
41-
throw Error('Test exited without clearing log.');
42+
if (!process.env.IS_BUILD) {
43+
if (!runtime.isLogEmpty()) {
44+
throw Error('Test exited without clearing log.');
45+
}
4246
}
4347
});
4448

@@ -138,6 +142,7 @@ describe('SchedulerPostTaskOnly', () => {
138142
};
139143
}
140144

145+
// @gate source
141146
it('task that finishes before deadline', () => {
142147
scheduleCallback(NormalPriority, () => {
143148
runtime.log('Task');
@@ -147,6 +152,7 @@ describe('SchedulerPostTaskOnly', () => {
147152
runtime.assertLog(['Task Event', 'Task']);
148153
});
149154

155+
// @gate source
150156
it('task with continuation', () => {
151157
scheduleCallback(NormalPriority, () => {
152158
runtime.log('Task');
@@ -167,6 +173,7 @@ describe('SchedulerPostTaskOnly', () => {
167173
runtime.assertLog(['Task Event', 'Continuation']);
168174
});
169175

176+
// @gate source
170177
it('multiple tasks', () => {
171178
scheduleCallback(NormalPriority, () => {
172179
runtime.log('A');
@@ -179,6 +186,7 @@ describe('SchedulerPostTaskOnly', () => {
179186
runtime.assertLog(['Task Event', 'A', 'B']);
180187
});
181188

189+
// @gate source
182190
it('multiple tasks with a yield in between', () => {
183191
scheduleCallback(NormalPriority, () => {
184192
runtime.log('A');
@@ -199,6 +207,7 @@ describe('SchedulerPostTaskOnly', () => {
199207
runtime.assertLog(['Task Event', 'B']);
200208
});
201209

210+
// @gate source
202211
it('cancels tasks', () => {
203212
const task = scheduleCallback(NormalPriority, () => {
204213
runtime.log('Task');
@@ -208,6 +217,7 @@ describe('SchedulerPostTaskOnly', () => {
208217
runtime.assertLog([]);
209218
});
210219

220+
// @gate source
211221
it('throws when a task errors then continues in a new event', () => {
212222
scheduleCallback(NormalPriority, () => {
213223
runtime.log('Oops!');
@@ -225,6 +235,7 @@ describe('SchedulerPostTaskOnly', () => {
225235
runtime.assertLog(['Task Event', 'Yay']);
226236
});
227237

238+
// @gate source
228239
it('schedule new task after queue has emptied', () => {
229240
scheduleCallback(NormalPriority, () => {
230241
runtime.log('A');
@@ -242,6 +253,7 @@ describe('SchedulerPostTaskOnly', () => {
242253
runtime.assertLog(['Task Event', 'B']);
243254
});
244255

256+
// @gate source
245257
it('schedule new task after a cancellation', () => {
246258
const handle = scheduleCallback(NormalPriority, () => {
247259
runtime.log('A');

0 commit comments

Comments
 (0)