-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathimmediate.test.ts
More file actions
48 lines (40 loc) · 1.4 KB
/
immediate.test.ts
File metadata and controls
48 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { setTimeout as sleep } from 'node:timers/promises';
import { mm, type MockApplication } from '@eggjs/mock';
import { describe, it, afterAll, beforeAll, expect } from 'vitest';
import { contains, getFixtures, getLogContent } from './utils.ts';
// TODO: flaky test on windows, Hook timed out in 20000ms
describe.skipIf(process.platform === 'win32')('cluster - immediate', () => {
let app: MockApplication;
beforeAll(async () => {
app = mm.cluster({ baseDir: getFixtures('immediate'), workers: 1 });
// app.debug();
await app.ready();
});
afterAll(() => app.close());
it('should work', async () => {
await sleep(5000);
const log = getLogContent('immediate');
// console.log(log);
expect(contains(log, 'immediate-interval')).toBeGreaterThanOrEqual(2);
expect(contains(log, 'immediate-cron')).toBeGreaterThanOrEqual(2);
});
});
describe.skipIf(process.platform === 'win32')('cluster - immediate-onlyonce', () => {
let app: MockApplication;
beforeAll(async () => {
app = mm.cluster({
baseDir: getFixtures('immediate-onlyonce'),
workers: 1,
});
// app.debug();
await app.ready();
});
afterAll(() => app.close());
it('should work', async () => {
await sleep(5000);
const log = getLogContent('immediate-onlyonce');
// console.log(log);
// unstable
expect(contains(log, 'immediate-onlyonce')).toBeGreaterThanOrEqual(0);
});
});