@testing-library/react
Advanced tools
Comparing version 9.3.0 to 9.3.1
@@ -9,8 +9,52 @@ 'use strict'; | ||
var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator')); | ||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends')); | ||
var React = _interopDefault(require('react')); | ||
var ReactDOM = _interopDefault(require('react-dom')); | ||
var dom = require('@testing-library/dom'); | ||
var testUtils = require('react-dom/test-utils'); | ||
var _extends = _interopDefault(require('@babel/runtime/helpers/extends')); | ||
var dom = require('@testing-library/dom'); | ||
/* istanbul ignore file */ | ||
// the part of this file that we need tested is definitely being run | ||
// and the part that is not cannot easily have useful tests written | ||
// anyway. So we're just going to ignore coverage for this file | ||
/** | ||
* copied from React's enqueueTask.js | ||
*/ | ||
var didWarnAboutMessageChannel = false; | ||
var enqueueTask; | ||
try { | ||
// read require off the module object to get around the bundlers. | ||
// we don't want them to detect a require and bundle a Node polyfill. | ||
var requireString = ("require" + Math.random()).slice(0, 7); | ||
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's | ||
// version of setImmediate, bypassing fake timers if any. | ||
enqueueTask = nodeRequire('timers').setImmediate; | ||
} catch (_err) { | ||
// we're in a browser | ||
// we can't use regular timers because they may still be faked | ||
// so we try MessageChannel+postMessage instead | ||
enqueueTask = function (callback) { | ||
if (didWarnAboutMessageChannel === false) { | ||
didWarnAboutMessageChannel = true; // eslint-disable-next-line no-console | ||
console.error(typeof MessageChannel !== 'undefined', 'This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.'); | ||
} | ||
var channel = new MessageChannel(); | ||
channel.port1.onmessage = callback; | ||
channel.port2.postMessage(undefined); | ||
}; | ||
} | ||
function flushMicroTasks() { | ||
return { | ||
then: function then(resolve) { | ||
enqueueTask(resolve); | ||
} | ||
}; | ||
} | ||
var reactAct = testUtils.act; | ||
@@ -341,23 +385,9 @@ var actSupported = reactAct !== undefined; // act is supported react-dom@16.8.0 | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee2() { | ||
return _regeneratorRuntime.wrap(function (_context2) { | ||
_regeneratorRuntime.mark(function _callee() { | ||
return _regeneratorRuntime.wrap(function (_context) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return asyncAct( | ||
/*#__PURE__*/ | ||
_asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee() { | ||
return _regeneratorRuntime.wrap(function (_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))); | ||
_context.next = 2; | ||
return flushMicroTasks(); | ||
@@ -369,6 +399,6 @@ case 2: | ||
case "end": | ||
return _context2.stop(); | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
}, _callee); | ||
}))); | ||
@@ -375,0 +405,0 @@ } |
import _regeneratorRuntime from '@babel/runtime/regenerator'; | ||
import _asyncToGenerator from '@babel/runtime/helpers/esm/asyncToGenerator'; | ||
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { act as act$1 } from 'react-dom/test-utils'; | ||
import _extends from '@babel/runtime/helpers/esm/extends'; | ||
import { configure, prettyDOM, getQueriesForElement, fireEvent as fireEvent$1 } from '@testing-library/dom'; | ||
export * from '@testing-library/dom'; | ||
import { act as act$1 } from 'react-dom/test-utils'; | ||
/* istanbul ignore file */ | ||
// the part of this file that we need tested is definitely being run | ||
// and the part that is not cannot easily have useful tests written | ||
// anyway. So we're just going to ignore coverage for this file | ||
/** | ||
* copied from React's enqueueTask.js | ||
*/ | ||
var didWarnAboutMessageChannel = false; | ||
var enqueueTask; | ||
try { | ||
// read require off the module object to get around the bundlers. | ||
// we don't want them to detect a require and bundle a Node polyfill. | ||
var requireString = ("require" + Math.random()).slice(0, 7); | ||
var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's | ||
// version of setImmediate, bypassing fake timers if any. | ||
enqueueTask = nodeRequire('timers').setImmediate; | ||
} catch (_err) { | ||
// we're in a browser | ||
// we can't use regular timers because they may still be faked | ||
// so we try MessageChannel+postMessage instead | ||
enqueueTask = function (callback) { | ||
if (didWarnAboutMessageChannel === false) { | ||
didWarnAboutMessageChannel = true; // eslint-disable-next-line no-console | ||
console.error(typeof MessageChannel !== 'undefined', 'This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.'); | ||
} | ||
var channel = new MessageChannel(); | ||
channel.port1.onmessage = callback; | ||
channel.port2.postMessage(undefined); | ||
}; | ||
} | ||
function flushMicroTasks() { | ||
return { | ||
then: function then(resolve) { | ||
enqueueTask(resolve); | ||
} | ||
}; | ||
} | ||
var reactAct = act$1; | ||
@@ -335,23 +379,9 @@ var actSupported = reactAct !== undefined; // act is supported react-dom@16.8.0 | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee2() { | ||
return _regeneratorRuntime.wrap(function (_context2) { | ||
_regeneratorRuntime.mark(function _callee() { | ||
return _regeneratorRuntime.wrap(function (_context) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context2.next = 2; | ||
return asyncAct( | ||
/*#__PURE__*/ | ||
_asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee() { | ||
return _regeneratorRuntime.wrap(function (_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))); | ||
_context.next = 2; | ||
return flushMicroTasks(); | ||
@@ -363,6 +393,6 @@ case 2: | ||
case "end": | ||
return _context2.stop(); | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
}, _callee); | ||
}))); | ||
@@ -369,0 +399,0 @@ } |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -7,3 +9,3 @@ value: true | ||
var _actCompat = require("./act-compat"); | ||
var _flushMicrotasks = _interopRequireDefault(require("./flush-microtasks")); | ||
@@ -29,5 +31,5 @@ var _pure = require("./pure"); | ||
afterEach(async () => { | ||
await (0, _actCompat.asyncAct)(async () => {}); | ||
await (0, _flushMicrotasks.default)(); | ||
(0, _pure.cleanup)(); | ||
}); | ||
} |
{ | ||
"name": "@testing-library/react", | ||
"version": "9.3.0", | ||
"version": "9.3.1", | ||
"description": "Simple and complete React DOM testing utilities that encourage good testing practices.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -32,3 +32,3 @@ <div align="center"> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-101-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors) | ||
[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] | ||
@@ -319,4 +319,4 @@ [![Join the community on Spectrum][spectrum-badge]][spectrum] | ||
If you are interested in testing a custom hook, check out | ||
[React Hooks Testing Library][react-hooks-testing-library]. | ||
If you are interested in testing a custom hook, check out [React Hooks Testing | ||
Library][react-hooks-testing-library]. | ||
@@ -520,2 +520,3 @@ > NOTE it is not recommended to test single-use custom hooks in isolation from | ||
<td align="center"><a href="https://github.com/danieljcafonso"><img src="https://avatars3.githubusercontent.com/u/35337607?v=4" width="100px;" alt="Daniel Afonso"/><br /><sub><b>Daniel Afonso</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=danieljcafonso" title="Code">๐ป</a> <a href="https://github.com/testing-library/react-testing-library/commits?author=danieljcafonso" title="Tests">โ ๏ธ</a></td> | ||
<td align="center"><a href="http://www.laurensbosscher.nl"><img src="https://avatars0.githubusercontent.com/u/13363196?v=4" width="100px;" alt="Laurens Bosscher"/><br /><sub><b>Laurens Bosscher</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=LaurensBosscher" title="Code">๐ป</a></td> | ||
</tr> | ||
@@ -522,0 +523,0 @@ </table> |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3346929
23
22536
568