From b6d575287e820bf6a3d9d164bb990177d63f5996 Mon Sep 17 00:00:00 2001 From: Jason Palmer Date: Wed, 1 Aug 2018 09:57:12 -0400 Subject: [PATCH] Update testURL default value from about:blank to localhost (#6792) ## Summary Updates jests default value for testURL from 'about:blank' to 'http://localhost'. This ensures that JSDOM doesn't throw a security error for tests using the jsdom environment. Should fix https://github.com/facebook/jest/issues/6766 --- CHANGELOG.md | 1 + e2e/__tests__/__snapshots__/show_config.test.js.snap | 2 +- .../src/lib/__tests__/__snapshots__/init.test.js.snap | 2 +- packages/jest-config/src/defaults.js | 2 +- packages/jest-config/src/valid_config.js | 2 +- packages/jest-validate/src/__tests__/fixtures/jest_config.js | 4 ++-- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34a678f8f119..50edbedf48b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes +- `[jest-config]` Update default config for testURL from 'about:blank' to 'http://localhost' to address latest JSDOM security warning. ([#6792](https://github.com/facebook/jest/pull/6792)) - `[jest-circus]` Fix retryTimes so errors are reset before re-running ([#6762](https://github.com/facebook/jest/pull/6762)) - `[docs]` Update `expect.objectContaining()` description ([#6754](https://github.com/facebook/jest/pull/6754)) - `[babel-jest]` Make `getCacheKey()` take into account `createTransformer` options ([#6699](https://github.com/facebook/jest/pull/6699)) diff --git a/e2e/__tests__/__snapshots__/show_config.test.js.snap b/e2e/__tests__/__snapshots__/show_config.test.js.snap index f6a773eaa247..e12bb522fdff 100644 --- a/e2e/__tests__/__snapshots__/show_config.test.js.snap +++ b/e2e/__tests__/__snapshots__/show_config.test.js.snap @@ -59,7 +59,7 @@ exports[`--showConfig outputs config info and exits 1`] = ` ], \\"testRegex\\": \\"\\", \\"testRunner\\": \\"<>/jest-jasmine2/build/index.js\\", - \\"testURL\\": \\"about:blank\\", + \\"testURL\\": \\"http://localhost\\", \\"timers\\": \\"real\\", \\"transform\\": [ [ diff --git a/packages/jest-cli/src/lib/__tests__/__snapshots__/init.test.js.snap b/packages/jest-cli/src/lib/__tests__/__snapshots__/init.test.js.snap index 8123bb5ac5d1..283bf34d2b16 100644 --- a/packages/jest-cli/src/lib/__tests__/__snapshots__/init.test.js.snap +++ b/packages/jest-cli/src/lib/__tests__/__snapshots__/init.test.js.snap @@ -174,7 +174,7 @@ module.exports = { // testRunner: \\"jasmine2\\", // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href - // testURL: \\"about:blank\\", + // testURL: \\"http://localhost\\", // Setting this value to \\"fake\\" allows the use of fake timers for functions such as \\"setTimeout\\" // timers: \\"real\\", diff --git a/packages/jest-config/src/defaults.js b/packages/jest-config/src/defaults.js index a4fc55e3be98..2ab932fce4cc 100644 --- a/packages/jest-config/src/defaults.js +++ b/packages/jest-config/src/defaults.js @@ -72,7 +72,7 @@ export default ({ testRegex: '', testResultsProcessor: null, testRunner: 'jasmine2', - testURL: 'about:blank', + testURL: 'http://localhost', timers: 'real', transform: null, transformIgnorePatterns: [NODE_MODULES_REGEXP], diff --git a/packages/jest-config/src/valid_config.js b/packages/jest-config/src/valid_config.js index 0079b1019dd1..9dd1f21abb95 100644 --- a/packages/jest-config/src/valid_config.js +++ b/packages/jest-config/src/valid_config.js @@ -96,7 +96,7 @@ export default ({ testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', testResultsProcessor: 'processor-node-module', testRunner: 'jasmine2', - testURL: 'about:blank', + testURL: 'http://localhost', timers: 'real', transform: { '^.+\\.js$': '/preprocessor.js', diff --git a/packages/jest-validate/src/__tests__/fixtures/jest_config.js b/packages/jest-validate/src/__tests__/fixtures/jest_config.js index bd11f9b35a27..742dce16ac5a 100644 --- a/packages/jest-validate/src/__tests__/fixtures/jest_config.js +++ b/packages/jest-validate/src/__tests__/fixtures/jest_config.js @@ -51,7 +51,7 @@ const defaultConfig = { testPathIgnorePatterns: [NODE_MODULES_REGEXP], testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', testResultsProcessor: null, - testURL: 'about:blank', + testURL: 'http://localhost', timers: 'real', transformIgnorePatterns: [NODE_MODULES_REGEXP], useStderr: false, @@ -116,7 +116,7 @@ const validConfig = { testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$', testResultsProcessor: 'processor-node-module', testRunner: 'jasmine2', - testURL: 'about:blank', + testURL: 'http://localhost', timers: 'real', transform: { '^.+\\.js$': '/preprocessor.js',