-
Notifications
You must be signed in to change notification settings - Fork 47.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made some incremental progress on Jest tests
- Loading branch information
Brian Vaughn
committed
Aug 15, 2019
1 parent
4c4f5fd
commit 7ce229d
Showing
9 changed files
with
80 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
// @flow | ||
'use strict'; | ||
|
||
import storage from 'local-storage-fallback'; | ||
// Import test renderer and then reset modules for two reasons: | ||
// 1. We don't want test renderer connected to the DevTools hooks. | ||
// 2. This enables us to work around the on-renderer limitation. | ||
// TODO This (or the resetModules below) might be the cause of the hooks erorr in some tests | ||
const ReactTestRenderer = require.requireActual('react-test-renderer'); | ||
|
||
// In case async/await syntax is used in a test. | ||
import 'regenerator-runtime/runtime'; | ||
jest.resetModules(); | ||
|
||
jest.mock('react-test-renderer', () => ReactTestRenderer); | ||
|
||
// DevTools stores preferences between sessions in localStorage | ||
if (!global.hasOwnProperty('localStorage')) { | ||
global.localStorage = storage; | ||
global.localStorage = require('local-storage-fallback').default; | ||
} | ||
|
||
// Mimic the global we set with Webpack's DefinePlugin | ||
global.__DEV__ = process.env.NODE_ENV !== 'production'; | ||
global.__TEST__ = process.env.NODE_ENV === 'test'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const baseConfig = require('./config.base'); | ||
|
||
module.exports = Object.assign({}, baseConfig, { | ||
testRegex: 'packages/react-devtools-shared/src/__tests__/[^]+.test.js$', | ||
modulePathIgnorePatterns: [], | ||
snapshotSerializers: [ | ||
require.resolve( | ||
'../../packages/react-devtools-shared/src/__tests__/inspectedElementSerializer.js' | ||
), | ||
require.resolve( | ||
'../../packages/react-devtools-shared/src/__tests__/storeSerializer.js' | ||
), | ||
], | ||
setupFiles: [ | ||
...baseConfig.setupFiles, | ||
require.resolve('./setupHostConfigs.js'), | ||
require.resolve( | ||
'../../packages/react-devtools-shared/src/__tests__/setupEnv.js' | ||
), | ||
], | ||
// TODO (Jest v24) Rename "setupFilesAfterEnv" after Jest upgrade | ||
setupTestFrameworkScriptFile: require.resolve( | ||
'../../packages/react-devtools-shared/src/__tests__/setupTests.js' | ||
), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1879,6 +1879,7 @@ array.prototype.find@^2.0.1: | |
arrify@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" | ||
integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= | ||
|
||
arrify@^2.0.1: | ||
version "2.0.1" | ||
|
@@ -3513,6 +3514,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" | ||
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== | ||
|
||
cookie@^0.3.1: | ||
version "0.3.1" | ||
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" | ||
integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= | ||
|
||
copy-concurrently@^1.0.0: | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0" | ||
|
@@ -7215,7 +7221,7 @@ jest-config@^23.6.0: | |
micromatch "^2.3.11" | ||
pretty-format "^23.6.0" | ||
|
||
jest-diff@^23.0.1, jest-diff@^23.6.0: | ||
jest-diff@^23, jest-diff@^23.6.0: | ||
version "23.6.0" | ||
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-23.6.0.tgz#1500f3f16e850bb3d71233408089be099f610c7d" | ||
integrity sha512-Gz9l5Ov+X3aL5L37IT+8hoCUsof1CVYBb2QEkOupK64XyRR3h+uRpYIm97K7sY8diFxowR8pIGEdyfMKTixo3g== | ||
|
@@ -7536,7 +7542,7 @@ jest-worker@^24.6.0: | |
merge-stream "^1.0.1" | ||
supports-color "^6.1.0" | ||
|
||
jest@^23.1.0: | ||
jest@^23: | ||
version "23.6.0" | ||
resolved "https://registry.yarnpkg.com/jest/-/jest-23.6.0.tgz#ad5835e923ebf6e19e7a1d7529a432edfee7813d" | ||
integrity sha512-lWzcd+HSiqeuxyhG+EnZds6iO3Y3ZEnMrfZq/OTGvF/C+Z4fPMCdhWTGSAiO2Oym9rbEXfwddHhh6jqrTF3+Lw== | ||
|
@@ -7941,6 +7947,13 @@ [email protected], loader-utils@^1.0.2, loader-utils@^1.1.0, loader-utils@^1.2. | |
emojis-list "^2.0.0" | ||
json5 "^1.0.1" | ||
|
||
local-storage-fallback@^4.1.1: | ||
version "4.1.1" | ||
resolved "https://registry.yarnpkg.com/local-storage-fallback/-/local-storage-fallback-4.1.1.tgz#6dc964635c8e9ab6d522d7d88538f465b62bd161" | ||
integrity sha512-Ka4rem1FOgvIaPMokxXTP8DgW8gjfAQSdJC8TGrplDug7vh3b0PZnY/9euG3O3cIGAvJLp33mMU6MJ13x6S+Pw== | ||
dependencies: | ||
cookie "^0.3.1" | ||
|
||
locate-path@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" | ||
|