-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathvitest-jest.js
47 lines (46 loc) · 1.54 KB
/
vitest-jest.js
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
const { patchSymbols } = require('@whatwg-node/disposablestack');
patchSymbols();
module.exports = new Proxy(require('@jest/globals'), {
get(jestGlobals, prop, receiver) {
if (prop === 'vitest' || prop === 'vi') {
return jestGlobals.jest;
}
if (prop === 'describe') {
const describeFn = function describe(name, ...args) {
return jestGlobals.describe(name, ...args);
};
describeFn.skipIf = function describeSkipIf(condition) {
return condition ? describeFn.skip : describeFn;
};
describeFn.skip = function describeSkip(name, ...args) {
return jestGlobals.describe.skip(name, ...args);
};
describeFn.only = function describeOnly(name, ...args) {
return jestGlobals.describe.only(name, ...args);
};
describeFn.each = function describeEach(table) {
return jestGlobals.describe.each(table);
};
return describeFn;
}
if (prop === 'it') {
const itFn = function it(name, ...args) {
return jestGlobals.it(name, ...args);
};
itFn.skipIf = function itSkipIf(condition) {
return condition ? itFn.skip : itFn;
};
itFn.skip = function itSkip(name, ...args) {
return jestGlobals.it.skip(name, ...args);
};
itFn.only = function itOnly(name, ...args) {
return jestGlobals.it.only(name, ...args);
};
itFn.each = function itEach(table) {
return jestGlobals.it.each(table);
};
return itFn;
}
return Reflect.get(jestGlobals, prop, receiver);
},
});