Skip to content

Commit

Permalink
test: mock fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Jun 12, 2024
1 parent 947de04 commit 0e9b46a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module.exports = {
preset: 'ts-jest',
silent: true,
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/esm/', '/example/'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
Expand Down
3 changes: 3 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const fetchMock = require('jest-fetch-mock');

fetchMock.enableMocks();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"husky": "8.0.2",
"is-ci": "3.0.1",
"jest": "29.3.1",
"jest-fetch-mock": "^3.0.3",
"prettier": "2.8.0",
"release-it": "15.5.0",
"rimraf": "3.0.2",
Expand Down
41 changes: 41 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ __metadata:
husky: 8.0.2
is-ci: 3.0.1
jest: 29.3.1
jest-fetch-mock: ^3.0.3
prettier: 2.8.0
release-it: 15.5.0
rimraf: 3.0.2
Expand Down Expand Up @@ -3264,6 +3265,15 @@ __metadata:
languageName: node
linkType: hard

"cross-fetch@npm:^3.0.4":
version: 3.1.8
resolution: "cross-fetch@npm:3.1.8"
dependencies:
node-fetch: ^2.6.12
checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632
languageName: node
linkType: hard

"cross-fetch@npm:^3.1.5":
version: 3.1.5
resolution: "cross-fetch@npm:3.1.5"
Expand Down Expand Up @@ -5866,6 +5876,16 @@ __metadata:
languageName: node
linkType: hard

"jest-fetch-mock@npm:^3.0.3":
version: 3.0.3
resolution: "jest-fetch-mock@npm:3.0.3"
dependencies:
cross-fetch: ^3.0.4
promise-polyfill: ^8.1.3
checksum: fb052f7e0ef1c8192a9c15efdd1b18d281ab68fc6b1648b30bff8880fe24418bdf12190ea79b1996932dc15417c3c01f5b2d77ef7104a7e7943e7cbe8d61071d
languageName: node
linkType: hard

"jest-get-type@npm:^29.4.3":
version: 29.4.3
resolution: "jest-get-type@npm:29.4.3"
Expand Down Expand Up @@ -6998,6 +7018,20 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:^2.6.12":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-gyp@npm:latest":
version: 9.3.1
resolution: "node-gyp@npm:9.3.1"
Expand Down Expand Up @@ -7611,6 +7645,13 @@ __metadata:
languageName: node
linkType: hard

"promise-polyfill@npm:^8.1.3":
version: 8.3.0
resolution: "promise-polyfill@npm:8.3.0"
checksum: 206373802076c77def0805758d0a8ece64120dfa6603f092404a1004211f8f2f67f33cadbc35953fc2a8ed0b0d38c774e88bdf01e20ce7a920723a60df84b7a5
languageName: node
linkType: hard

"promise-retry@npm:^2.0.1":
version: 2.0.1
resolution: "promise-retry@npm:2.0.1"
Expand Down

0 comments on commit 0e9b46a

Please sign in to comment.