forked from nodejs/corepack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupTests.js
More file actions
31 lines (25 loc) · 651 Bytes
/
setupTests.js
File metadata and controls
31 lines (25 loc) · 651 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
28
29
30
31
/* global jest, expect, beforeEach, afterAll */
const crypto = require(`crypto`);
jest.retryTimes(2, {logErrorsBeforeRetry: true});
switch (process.env.NOCK_ENV || ``) {
case `record`:
case `replay`:
beforeEach(() => {
process.env.RUN_CLI_ID = 0;
process.env.NOCK_FILE_NAME = crypto
.createHash(`md5`)
.update(expect.getState().currentTestName)
.digest(`base64url`);
});
afterAll(() => {
delete process.env.RUN_CLI_ID;
delete process.env.NOCK_FILE_NAME;
});
break;
case ``: {
// Nothing
} break;
default: {
throw new Error(`Invalid NOCK_ENV variable`);
}
}