-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcurrent.ts
82 lines (68 loc) · 2.25 KB
/
concurrent.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
describe('My tests', () => {
describe('first group', () => {
it.concurrent('first', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'first'};
expect(result).toMatchSnapshot('first')
});
it.concurrent('second', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'second'};
expect(result).toMatchSnapshot('second')
});
it.concurrent('third', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'third'};
expect(result).toMatchSnapshot('third')
});
it.concurrent('fourth', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'fourth'};
expect(result).toMatchSnapshot('fourth')
});
it.concurrent('fifth', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'fifth'};
expect(result).toMatchSnapshot('fifth')
});
});
describe('second group', () => {
it.concurrent('first', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'first', group:2};
expect(result).toMatchSnapshot('2_first')
});
it.concurrent('second', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'second', group:2};
expect(result).toMatchSnapshot('2_second')
});
it.concurrent('third', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'third', group:2};
expect(result).toMatchSnapshot('2_third')
});
it.concurrent('fourth', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'fourth', group:2};
expect(result).toMatchSnapshot('2_fourth')
});
it.concurrent('fifth', async () => {
await wait(getRandomInt(100, 1000));
const result = {data: 'fifth', group:2};
expect(result).toMatchSnapshot('2_fifth')
});
});
});
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
function wait(time: number) {
return new Promise((resolve) => {
setTimeout(() => { // simulate a server delay
resolve();
}, time);
});
}