From 344458b7d4fea60843257b7dc078cb3bc98b4a79 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 08:41:41 +0000 Subject: [PATCH 1/4] fix(deps): update dependency axios to v1 --- package.json | 2 +- pnpm-lock.yaml | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 014e9f1a8..0fac5c3fc 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ }, "dependencies": { "@primer/octicons-react": "19.8.0", - "axios": "0.27.2", + "axios": "1.5.1", "date-fns": "2.30.0", "electron-updater": "6.1.4", "final-form": "4.20.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e3362eda..bcbe86733 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: 19.8.0 version: 19.8.0(react@18.2.0) axios: - specifier: 0.27.2 - version: 0.27.2 + specifier: 1.5.1 + version: 1.5.1 date-fns: specifier: 2.30.0 version: 2.30.0 @@ -1541,11 +1541,12 @@ packages: resolution: {integrity: sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==} dev: true - /axios@0.27.2: - resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} + /axios@1.5.1: + resolution: {integrity: sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==} dependencies: follow-redirects: 1.15.2 form-data: 4.0.0 + proxy-from-env: 1.1.0 transitivePeerDependencies: - debug dev: false @@ -4649,6 +4650,10 @@ packages: requiresBuild: true optional: true + /proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + dev: false + /psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} dev: true From c381461940e7514cd1630093ef4c467afbe4ff68 Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Mon, 2 Oct 2023 10:45:26 +0200 Subject: [PATCH 2/4] Use new adapter setting See https://github.com/axios/axios/pull/5277 --- src/hooks/useNotifications.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index b9ab59296..593689b4a 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -9,7 +9,7 @@ import { mockedUser } from '../__mocks__/mockedData'; describe('hooks/useNotifications.ts', () => { beforeEach(() => { - axios.defaults.adapter = require('axios/lib/adapters/http'); + axios.defaults.adapter = 'http'; }); describe('fetchNotifications', () => { From 3cf31f5f5f5a76c13fd15f2146f1cb6f846a00cc Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Tue, 3 Oct 2023 12:12:32 +0200 Subject: [PATCH 3/4] Fix tests --- jest.config.js | 20 ++++++++++++++++++++ package.json | 12 ------------ src/hooks/useNotifications.test.ts | 2 ++ 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 jest.config.js diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..da0781231 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,20 @@ +const config = { + "preset": "ts-jest/presets/js-with-ts", + "setupFiles": [ + "/src/__helpers__/setupEnvVars.js" + ], + "testEnvironment": "jsdom", + "coverageThreshold": { + "global": { + "lines": 90 + } + }, + "transformIgnorePatterns": ["node_modules\/(?!axios)"], + "moduleNameMapper": { + // Force CommonJS build for http adapter to be available. + // via https://github.com/axios/axios/issues/5101#issuecomment-1276572468 + '^axios$': require.resolve('axios'), + }, +} + +module.exports = config; diff --git a/package.json b/package.json index 0fac5c3fc..9e85b0cd0 100644 --- a/package.json +++ b/package.json @@ -48,18 +48,6 @@ "url": "https://github.com/manosim/gitify/issues" }, "homepage": "https://www.gitify.io/", - "jest": { - "preset": "ts-jest/presets/js-with-ts", - "setupFiles": [ - "/src/__helpers__/setupEnvVars.js" - ], - "testEnvironment": "jsdom", - "coverageThreshold": { - "global": { - "lines": 90 - } - } - }, "build": { "appId": "com.electron.gitify", "productName": "Gitify", diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index 593689b4a..dce5e9e18 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -9,6 +9,8 @@ import { mockedUser } from '../__mocks__/mockedData'; describe('hooks/useNotifications.ts', () => { beforeEach(() => { + // axios will default to using the XHR adapter which can't be intercepted + // by nock. So, configure axios to use the node adapter. axios.defaults.adapter = 'http'; }); From 968ef26f5812c0c4d38fe447c1aff210fa5c3132 Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Tue, 3 Oct 2023 12:14:47 +0200 Subject: [PATCH 4/4] Remove unnecessary transform --- jest.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index da0781231..f412fe027 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,7 +9,6 @@ const config = { "lines": 90 } }, - "transformIgnorePatterns": ["node_modules\/(?!axios)"], "moduleNameMapper": { // Force CommonJS build for http adapter to be available. // via https://github.com/axios/axios/issues/5101#issuecomment-1276572468