Add jest-fetch-mock as dev dependency (#528)

Also add config/jest/setupJest.js so we can configure jest-fetch-mock

Test plan: I have verified that mocked fetch works as expected in a
downstream commit.
This commit is contained in:
Dandelion Mané 2018-07-26 15:08:14 -07:00 committed by GitHub
parent e0c97fee9e
commit e06b88364e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

3
config/jest/setupJest.js Normal file
View File

@ -0,0 +1,3 @@
// @flow
global.fetch = require("jest-fetch-mock");

View File

@ -78,7 +78,8 @@
"src/**/*.{js,jsx,mjs}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
"<rootDir>/config/polyfills.js",
"<rootDir>/config/jest/setupJest.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
@ -116,6 +117,7 @@
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.3",
"jest-fetch-mock": "^1.6.5",
"mkdirp": "^0.5.1",
"static-site-generator-webpack-plugin": "^3.4.1",
"tmp": "^0.0.33",

View File

@ -56,6 +56,10 @@
dependencies:
seedrandom "~2.4.3"
"@types/jest@^23.0.0":
version "23.3.0"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-23.3.0.tgz#5dd70033b616a6228042244ebd992f6426808810"
"@types/node@*":
version "9.4.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275"
@ -3936,6 +3940,14 @@ jest-environment-node@^20.0.3:
jest-mock "^20.0.3"
jest-util "^20.0.3"
jest-fetch-mock@^1.6.5:
version "1.6.5"
resolved "https://registry.yarnpkg.com/jest-fetch-mock/-/jest-fetch-mock-1.6.5.tgz#178fa1a937ef6f61fb8e8483b6d4602b17e0d96d"
dependencies:
"@types/jest" "^23.0.0"
isomorphic-fetch "^2.2.1"
promise-polyfill "^7.1.1"
jest-haste-map@^20.0.4:
version "20.0.5"
resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-20.0.5.tgz#abad74efb1a005974a7b6517e11010709cab9112"
@ -5488,6 +5500,10 @@ progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
promise-polyfill@^7.1.1:
version "7.1.2"
resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-7.1.2.tgz#ab05301d8c28536301622d69227632269a70ca3b"
promise@8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-8.0.1.tgz#e45d68b00a17647b6da711bf85ed6ed47208f450"