forked from cagov/unemployment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupTestFramework.js
75 lines (66 loc) · 1.7 KB
/
setupTestFramework.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
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
import "dotenv/config";
import Adapter from "enzyme-adapter-react-16";
import Enzyme from "enzyme";
// Setup Enzyme for React component tests
Enzyme.configure({ adapter: new Adapter() });
// Mock manifest files, which are generated as part of the build process
jest.mock(
"./src/data/manifest-scripts.json",
() => ({
client: {
js: "/mocked-client.js",
},
}),
{ virtual: true }
);
jest.mock(
"./src/data/manifest-styles.json",
() => ({
"App.css": "mocked-app.css",
}),
{ virtual: true }
);
// Google's test environment secret
process.env.RECAPTCHA_SECRET = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe";
process.env.COSMOS_DB_KEY = "mock-cosmos-db-key";
jest.mock("@azure/cosmos", () => {
const actual = jest.requireActual("@azure/cosmos");
return {
...actual,
CosmosClient: jest.fn(),
};
});
jest.mock("./src/data/cosmosConfig", () => jest.fn());
jest.mock("./src/data/cosmos");
const cosmos = require("./src/data/cosmos");
cosmos.createRetroCertDatabase(jest.fn());
jest.mock("react-router-dom", () => {
const actual = jest.requireActual("react-router-dom");
return {
...actual,
useHistory: () => ({
push: jest.fn(),
listen: jest.fn(),
location: { state: { isReturning: true } },
}),
useLocation: () => {
return {};
},
};
});
jest.mock("uuid", () => {
const actual = jest.requireActual("uuid");
return {
...actual,
v4: () => "00000000-fake-mock-fake-123456789012",
};
});
// window.gtag is added by Google Analytics. Mock out the calls.
jest.mock("./src/client/utils", () => {
const actual = jest.requireActual("./src/client/utils");
return {
...actual,
logEvent: (a, b, c) => {},
logPage: (a) => {},
};
});