diff --git a/CHANGELOG.md b/CHANGELOG.md index bc329dea845c..3023b3194ae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## master ### Fixes + * `[expect]` fix .toThrow for promises ([#4884](https://github.com/facebook/jest/pull/4884)) * `[jest-docblock]` pragmas should preserve urls @@ -46,7 +47,6 @@ * `[jest-cli]` Fix `--onlyChanged` path case sensitivity on Windows platform ([#4730](https://github.com/facebook/jest/pull/4730)) - ### Features * `[jest-mock]` Add `timestamps` to mock state. @@ -104,6 +104,9 @@ ([#4497](https://github.com/facebook/jest/pull/4497)) * `[jest-jasmine2]` Add `testLocationInResults` flag to add location information per spec to test results ([#4782](https://github.com/facebook/jest/pull/4782)) +* `[jest-environment-jsdom]` Update JSOM to 11.4, which includes built-in + support for `requestAnimationFrame` + ([#4919](https://github.com/facebook/jest/pull/4919)) ### Chore & Maintenance @@ -134,7 +137,7 @@ ([#4578](https://github.com/facebook/jest/pull/4578)) * `[jest-runtime]` Add `.advanceTimersByTime`; keep `.runTimersToTime()` as an alias. -* `[docs]` Include missing dependency in TestEnvironment sample code +* `[docs]` Include missing dependency in TestEnvironment sample code * `[docs]` Add clarification for hook execution order ## jest 21.2.1 diff --git a/integration_tests/__tests__/request_animation_frame.test.js b/integration_tests/__tests__/request_animation_frame.test.js deleted file mode 100644 index 383291d1f604..000000000000 --- a/integration_tests/__tests__/request_animation_frame.test.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ -'use strict'; - -const runJest = require('../runJest'); - -test('requestAnimationFrame', () => { - const result = runJest('request_animation_frame', ['--verbose']); - const stderr = result.stderr.toString(); - - expect(stderr).toMatch('requestAnimationFrame test'); - expect(result.status).toBe(0); -}); diff --git a/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js b/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js deleted file mode 100644 index e08ca6f1db1a..000000000000 --- a/integration_tests/request_animation_frame/__tests__/request_animation_frame.test.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* eslint-env browser */ - -'use strict'; - -test('requestAnimationFrame test', done => { - expect.hasAssertions(); - - requestAnimationFrame(timestamp => { - expect(true).toBe(true); - expect(timestamp).toBeGreaterThan(0); - - done(); - }); -}); - -test('cancelAnimationFrame test', done => { - // Will be immediately cancelled. Must never run. - cancelAnimationFrame( - requestAnimationFrame(() => { - done.fail(); - }) - ); - - // Make sure it has not fired. - const REASONABLE_TIME = 100; - setTimeout(() => { - done(); - }, REASONABLE_TIME); -}); diff --git a/integration_tests/request_animation_frame/package.json b/integration_tests/request_animation_frame/package.json deleted file mode 100644 index 0ded940b7cb7..000000000000 --- a/integration_tests/request_animation_frame/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "jest": { - "testEnvironment": "jsdom" - } -} diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json index 7f13977e6b81..d236881b0932 100644 --- a/packages/jest-environment-jsdom/package.json +++ b/packages/jest-environment-jsdom/package.json @@ -10,6 +10,6 @@ "dependencies": { "jest-mock": "^21.2.0", "jest-util": "^21.2.1", - "jsdom": "~11.2.0" + "jsdom": "^11.4.0" } } diff --git a/packages/jest-environment-jsdom/src/index.js b/packages/jest-environment-jsdom/src/index.js index d3d2212d72ec..11248961000e 100644 --- a/packages/jest-environment-jsdom/src/index.js +++ b/packages/jest-environment-jsdom/src/index.js @@ -26,6 +26,7 @@ class JSDOMEnvironment { const jsdomInitialized = process.hrtime(); this.dom = new JSDOM('', { + pretendToBeVisual: true, runScripts: 'dangerously', url: config.testURL, }); @@ -35,19 +36,6 @@ class JSDOMEnvironment { this.global.Error.stackTraceLimit = 100; installCommonGlobals(global, config.globals); - if (!global.requestAnimationFrame || !global.cancelAnimationFrame) { - global.requestAnimationFrame = callback => { - const hr = process.hrtime(jsdomInitialized); - const hrInNano = hr[0] * 1e9 + hr[1]; - const hrInMicro = hrInNano / 1e6; - - return global.setTimeout(callback, 0, hrInMicro); - }; - global.cancelAnimationFrame = id => { - return global.clearTimeout(id); - }; - } - // Report uncaught errors. this.errorEventListener = event => { if (userErrorListenerCount === 0 && event.error) { diff --git a/yarn.lock b/yarn.lock index 1f7cfaf74add..825a5f5e1286 100644 --- a/yarn.lock +++ b/yarn.lock @@ -34,11 +34,11 @@ accepts@1.3.3: mime-types "~2.1.11" negotiator "0.6.1" -acorn-globals@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-3.1.0.tgz#fd8270f71fbb4996b004fa880ee5d46573a731bf" +acorn-globals@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538" dependencies: - acorn "^4.0.4" + acorn "^5.0.0" acorn-jsx@^3.0.0: version "3.0.1" @@ -50,13 +50,13 @@ acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^4.0.1, acorn@^4.0.3, acorn@^4.0.4: +acorn@^4.0.1, acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" +acorn@^5.0.0, acorn@^5.1.1, acorn@^5.1.2: + version "5.2.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" add-stream@^1.0.0: version "1.0.0" @@ -1092,6 +1092,10 @@ browser-pack@^6.0.1: through2 "^2.0.0" umd "^3.0.0" +browser-process-hrtime@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e" + browser-resolve@^1.11.0, browser-resolve@^1.11.2, browser-resolve@^1.7.0: version "1.11.2" resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" @@ -2081,6 +2085,10 @@ domelementtype@~1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" +domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.0.tgz#81fe5df81b3f057052cde3a9fa9bf536a85b9ab0" + domhandler@^2.3.0: version "2.4.1" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.1.tgz#892e47000a99be55bbf3774ffea0561d8879c259" @@ -2250,7 +2258,7 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -escodegen@^1.6.1: +escodegen@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.0.tgz#9811a2f265dc1cd3894420ee3717064b632b8852" dependencies: @@ -3588,30 +3596,32 @@ jschardet@^1.4.2: version "1.5.1" resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-1.5.1.tgz#c519f629f86b3a5bedba58a88d311309eec097f9" -jsdom@~11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.2.0.tgz#4f6b8736af3357c3af7227a3b54a5bda1c513fd6" +jsdom@^11.4.0: + version "11.4.0" + resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.4.0.tgz#a3941a9699cbb0d61f8ab86f6f28f4ad5ea60d04" dependencies: abab "^1.0.3" - acorn "^4.0.4" - acorn-globals "^3.1.0" + acorn "^5.1.2" + acorn-globals "^4.0.0" array-equal "^1.0.0" + browser-process-hrtime "^0.1.2" content-type-parser "^1.0.1" cssom ">= 0.3.2 < 0.4.0" cssstyle ">= 0.2.37 < 0.3.0" - escodegen "^1.6.1" + domexception "^1.0.0" + escodegen "^1.9.0" html-encoding-sniffer "^1.0.1" - nwmatcher "^1.4.1" + nwmatcher "^1.4.3" parse5 "^3.0.2" pn "^1.0.0" - request "^2.79.0" + request "^2.83.0" request-promise-native "^1.0.3" sax "^1.2.1" symbol-tree "^3.2.1" - tough-cookie "^2.3.2" - webidl-conversions "^4.0.0" + tough-cookie "^2.3.3" + webidl-conversions "^4.0.2" whatwg-encoding "^1.0.1" - whatwg-url "^6.1.0" + whatwg-url "^6.3.0" xml-name-validator "^2.0.1" jsesc@^1.3.0: @@ -4406,7 +4416,7 @@ number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" -nwmatcher@^1.4.1: +nwmatcher@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.3.tgz#64348e3b3d80f035b40ac11563d278f8b72db89c" @@ -5170,7 +5180,7 @@ request@2.81.0, request@^2.81.0: tunnel-agent "^0.6.0" uuid "^3.0.0" -request@^2.79.0: +request@^2.83.0: version "2.83.0" resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" dependencies: @@ -5864,7 +5874,7 @@ to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" -tough-cookie@>=2.3.3, tough-cookie@^2.3.2, tough-cookie@~2.3.3: +tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" dependencies: @@ -6135,7 +6145,7 @@ weak@^1.0.1: bindings "^1.2.1" nan "^2.0.5" -webidl-conversions@^4.0.0, webidl-conversions@^4.0.1: +webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -6149,7 +6159,7 @@ whatwg-fetch@>=0.10.0: version "2.0.3" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" -whatwg-url@^6.1.0: +whatwg-url@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.3.0.tgz#597ee5488371abe7922c843397ddec1ae94c048d" dependencies: