diff --git a/build/jest/base-jest-config.js b/build/jest/base-jest-config.js index 56a1b670..1b2f74c7 100644 --- a/build/jest/base-jest-config.js +++ b/build/jest/base-jest-config.js @@ -11,18 +11,27 @@ const testFolder = process.env.TEST_FOLDER || '__tests__'; function getReactVersion() { + // $FlowFixMe + const meta = require(process.cwd() + '/package.json'); + const react = + (meta.dependencies && meta.dependencies.react) || + (meta.devDependencies && meta.devDependencies.react) || + (meta.peerDependencies && meta.peerDependencies.react); + return react + .split('.') + .shift() + .match(/\d+/); +} +function getReactSetup() { try { - // $FlowFixMe - const meta = require(process.cwd() + '/package.json'); - return meta.dependencies.react - .split('.') - .shift() - .match(/\d+/); + return [require.resolve(`./jest-framework-setup-${getReactVersion()}.js`)]; } catch (e) { - return '16'; + return []; } } +const reactSetup = getReactSetup(); + module.exports = { cache: false, coverageDirectory: `${process.cwd()}/coverage`, @@ -32,11 +41,9 @@ module.exports = { '^.+\\.js$': require.resolve('./jest-transformer.js'), }, transformIgnorePatterns: ['/node_modules/(?!(fusion-cli.*build))'], - setupFiles: [ - require.resolve('./jest-framework-shims.js'), - require.resolve(`./jest-framework-setup-${getReactVersion()}.js`), - ], - snapshotSerializers: [require.resolve('enzyme-to-json/serializer')], + setupFiles: [require.resolve('./jest-framework-shims.js'), ...reactSetup], + snapshotSerializers: + reactSetup.length > 0 ? [require.resolve('enzyme-to-json/serializer')] : [], testMatch: [`**/${testFolder}/**/*.js`], testURL: 'http://localhost:3000/', collectCoverageFrom: [ diff --git a/build/server-error.js b/build/server-error.js index 8b3e5bc0..9a0c5624 100644 --- a/build/server-error.js +++ b/build/server-error.js @@ -8,15 +8,7 @@ /* eslint-env node */ -const React = require('react'); -const RedBox = require('redbox-react').RedBoxError; -const ReactDOMServer = require('react-dom/server'); - function renderError(error /*: any */ = {}) { - const content = [ - '
${displayError.stack.replace(/\[\d\dm/gm, '')}+ + + `; } module.exports.renderError = renderError; diff --git a/package.json b/package.json index e51c3e8b..3ace039f 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "progress-bar-webpack-plugin": "^1.11.0", "range-parser": "^1.2.0", "react-dev-utils": "^5.0.1", - "redbox-react": "^1.6.0", "request": "^2.87.0", "resolve-from": "^4.0.0", "rimraf": "^2.6.2", @@ -104,7 +103,6 @@ "tape": "4.9.1" }, "peerDependencies": { - "enzyme": "^3.3.0", "fusion-core": "^1.5.0-beta.0", "fusion-tokens": "^1.0.4" }, diff --git a/test/fixtures/test-jest-app/package.json b/test/fixtures/test-jest-app/package.json new file mode 100644 index 00000000..01e850d3 --- /dev/null +++ b/test/fixtures/test-jest-app/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "react": "16.4.2" + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index ae08039a..965c0ce3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2659,12 +2659,6 @@ error-inject@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/error-inject/-/error-inject-1.0.0.tgz#e2b3d91b54aed672f309d950d154850fa11d4f37" -error-stack-parser@^1.3.6: - version "1.3.6" - resolved "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-1.3.6.tgz#e0e73b93e417138d1cd7c0b746b1a4a14854c292" - dependencies: - stackframe "^0.3.1" - es-abstract@^1.10.0, es-abstract@^1.5.0, es-abstract@^1.5.1, es-abstract@^1.6.1, es-abstract@^1.7.0: version "1.12.0" resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165" @@ -6059,7 +6053,7 @@ prompts@^0.1.9: kleur "^2.0.1" sisteransi "^0.1.1" -prop-types@^15.5.4, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2: +prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2: version "15.6.2" resolved "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" dependencies: @@ -6392,15 +6386,6 @@ recursive-readdir@2.2.1: dependencies: minimatch "3.0.3" -redbox-react@^1.6.0: - version "1.6.0" - resolved "https://registry.npmjs.org/redbox-react/-/redbox-react-1.6.0.tgz#e753ac02595bc1bf695b3935889a4f5b1b5a21a1" - dependencies: - error-stack-parser "^1.3.6" - object-assign "^4.0.1" - prop-types "^15.5.4" - sourcemapped-stacktrace "^1.1.6" - regenerate-unicode-properties@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-7.0.0.tgz#107405afcc4a190ec5ed450ecaa00ed0cafa7a4c" @@ -6964,10 +6949,6 @@ source-map-url@^0.4.0: version "0.4.0" resolved "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" -source-map@0.5.6: - version "0.5.6" - resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" - source-map@^0.4.4: version "0.4.4" resolved "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" @@ -6986,12 +6967,6 @@ source-map@^0.7.2: version "0.7.3" resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" -sourcemapped-stacktrace@^1.1.6: - version "1.1.8" - resolved "https://registry.npmjs.org/sourcemapped-stacktrace/-/sourcemapped-stacktrace-1.1.8.tgz#6b7a3f1a6fb15f6d40e701e23ce404553480d688" - dependencies: - source-map "0.5.6" - spdx-correct@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82" @@ -7057,10 +7032,6 @@ stack-utils@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620" -stackframe@^0.3.1: - version "0.3.1" - resolved "https://registry.npmjs.org/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" - static-extend@^0.1.1: version "0.1.2" resolved "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"