forked from getsentry/sentry-javascript-bundler-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestIf.ts
More file actions
27 lines (24 loc) · 951 Bytes
/
testIf.ts
File metadata and controls
27 lines (24 loc) · 951 Bytes
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
const [NODE_MAJOR_VERSION] = process.version.replace("v", "").split(".").map(Number) as [number];
// eslint-disable-next-line no-undef
export function testIf(condition: boolean): jest.It {
if (condition) {
// eslint-disable-next-line no-undef
return test;
} else {
// eslint-disable-next-line no-undef
return test.skip;
}
}
/**
* Webpack 4 doesn't work for Node.js versions >= 18.
* We can use this function to skip tests on Webpack 4.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-undef, @typescript-eslint/no-unsafe-assignment
export const testIfNodeMajorVersionIsLessThan18: jest.It = function () {
return testIf(NODE_MAJOR_VERSION < 18);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
// eslint-disable-next-line no-undef
export const describeNode18Plus: jest.Describe =
// eslint-disable-next-line no-undef
NODE_MAJOR_VERSION >= 18 ? describe : describe.skip;