Skip to content

Commit 3cf31f5

Browse files
author
Brendan Mulholland
committed
Fix tests
1 parent c381461 commit 3cf31f5

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

jest.config.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const config = {
2+
"preset": "ts-jest/presets/js-with-ts",
3+
"setupFiles": [
4+
"<rootDir>/src/__helpers__/setupEnvVars.js"
5+
],
6+
"testEnvironment": "jsdom",
7+
"coverageThreshold": {
8+
"global": {
9+
"lines": 90
10+
}
11+
},
12+
"transformIgnorePatterns": ["node_modules\/(?!axios)"],
13+
"moduleNameMapper": {
14+
// Force CommonJS build for http adapter to be available.
15+
// via https://github.com/axios/axios/issues/5101#issuecomment-1276572468
16+
'^axios$': require.resolve('axios'),
17+
},
18+
}
19+
20+
module.exports = config;

package.json

-12
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@
4848
"url": "https://github.com/manosim/gitify/issues"
4949
},
5050
"homepage": "https://www.gitify.io/",
51-
"jest": {
52-
"preset": "ts-jest/presets/js-with-ts",
53-
"setupFiles": [
54-
"<rootDir>/src/__helpers__/setupEnvVars.js"
55-
],
56-
"testEnvironment": "jsdom",
57-
"coverageThreshold": {
58-
"global": {
59-
"lines": 90
60-
}
61-
}
62-
},
6351
"build": {
6452
"appId": "com.electron.gitify",
6553
"productName": "Gitify",

src/hooks/useNotifications.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { mockedUser } from '../__mocks__/mockedData';
99

1010
describe('hooks/useNotifications.ts', () => {
1111
beforeEach(() => {
12+
// axios will default to using the XHR adapter which can't be intercepted
13+
// by nock. So, configure axios to use the node adapter.
1214
axios.defaults.adapter = 'http';
1315
});
1416

0 commit comments

Comments
 (0)