From 8b8d035c5f140b0ff04eba1eac3dd01bf668b65f Mon Sep 17 00:00:00 2001 From: Marco Moretti Date: Mon, 7 Dec 2020 22:59:29 +0100 Subject: [PATCH 1/7] chore: add eslint as dep of the project (#512) * chore: add eslint as dep of the project * chore: remove pin --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5c94d467..e828b966 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ "kcd-scripts": "7.5.1", "react": "17.0.1", "react-test-renderer": "17.0.1", - "typescript": "4.1.2" + "typescript": "4.1.2", + "eslint": "7.14.0" }, "peerDependencies": { "react": ">=16.9.0", From ca075a62664aaf00c464a4f147fde2a1fedce4ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 09:56:30 +1100 Subject: [PATCH 2/7] chore(deps-dev): bump eslint from 7.14.0 to 7.15.0 (#513) Bumps [eslint](https://github.com/eslint/eslint) from 7.14.0 to 7.15.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.14.0...v7.15.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e828b966..a4ad8e9d 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "react": "17.0.1", "react-test-renderer": "17.0.1", "typescript": "4.1.2", - "eslint": "7.14.0" + "eslint": "7.15.0" }, "peerDependencies": { "react": ">=16.9.0", From f9ff593829f0db21df9558b9e29bd0392325b938 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 12:03:54 +1100 Subject: [PATCH 3/7] chore(deps-dev): bump kcd-scripts from 7.5.1 to 7.5.2 (#514) Bumps [kcd-scripts](https://github.com/kentcdodds/kcd-scripts) from 7.5.1 to 7.5.2. - [Release notes](https://github.com/kentcdodds/kcd-scripts/releases) - [Changelog](https://github.com/kentcdodds/kcd-scripts/blob/master/CHANGELOG.md) - [Commits](https://github.com/kentcdodds/kcd-scripts/compare/v7.5.1...v7.5.2) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4ad8e9d..cb1f5f57 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "docz": "2.3.1", "docz-theme-default": "1.2.0", "docz-utils": "2.3.0", - "kcd-scripts": "7.5.1", + "kcd-scripts": "7.5.2", "react": "17.0.1", "react-test-renderer": "17.0.1", "typescript": "4.1.2", From 77eb8a81319b0a6beb4dc3025bbbef4e0f541076 Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Tue, 8 Dec 2020 13:39:08 +1100 Subject: [PATCH 4/7] chore(README): Move TOC below the header in the README --- README.md | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 8b85da82..b970a86c 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,3 @@ - - - -- [react-hooks-testing-library](#react-hooks-testing-library) - - [The problem](#the-problem) - - [The solution](#the-solution) - - [When to use this library](#when-to-use-this-library) - - [When not to use this library](#when-not-to-use-this-library) - - [Example](#example) - - [`useCounter.js`](#usecounterjs) - - [`useCounter.test.js`](#usecountertestjs) - - [Installation](#installation) - - [Peer Dependencies](#peer-dependencies) - - [API](#api) - - [Contributors](#contributors) - - [Issues](#issues) - - [🐛 Bugs](#-bugs) - - [💡 Feature Requests](#-feature-requests) - - [❓ Questions](#-questions) - - [LICENSE](#license) - - -

react-hooks-testing-library

@@ -58,6 +35,32 @@ [![Watch on GitHub](https://img.shields.io/github/watchers/testing-library/react-hooks-testing-library.svg?style=social)](https://github.com/testing-library/react-hooks-testing-library/watchers) [![Star on GitHub](https://img.shields.io/github/stars/testing-library/react-hooks-testing-library.svg?style=social)](https://github.com/testing-library/react-hooks-testing-library/stargazers) [![Tweet](https://img.shields.io/twitter/url/https/github.com/testing-library/react-hooks-testing-library.svg?style=social)](https://twitter.com/intent/tweet?text=Check%20out%20react-hooks-testing-library%20by%20%40testing-library%20https%3A%2F%2Fgithub.com%2Ftesting-library%2Freact-hooks-testing-library%20%F0%9F%91%8D) + + +## Table of Contents + + + + +- [react-hooks-testing-library](#react-hooks-testing-library) + - [The problem](#the-problem) + - [The solution](#the-solution) + - [When to use this library](#when-to-use-this-library) + - [When not to use this library](#when-not-to-use-this-library) + - [Example](#example) + - [`useCounter.js`](#usecounterjs) + - [`useCounter.test.js`](#usecountertestjs) + - [Installation](#installation) + - [Peer Dependencies](#peer-dependencies) + - [API](#api) + - [Contributors](#contributors) + - [Issues](#issues) + - [🐛 Bugs](#-bugs) + - [💡 Feature Requests](#-feature-requests) + - [❓ Questions](#-questions) + - [LICENSE](#license) + + ## The problem From d92431ebe0dc8c8d188cb5ebe7b489d1f7f7fd1f Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Tue, 8 Dec 2020 13:44:14 +1100 Subject: [PATCH 5/7] chore(README): format TOC after moving it --- README.md | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b970a86c..72ef55a9 100644 --- a/README.md +++ b/README.md @@ -42,23 +42,22 @@ -- [react-hooks-testing-library](#react-hooks-testing-library) - - [The problem](#the-problem) - - [The solution](#the-solution) - - [When to use this library](#when-to-use-this-library) - - [When not to use this library](#when-not-to-use-this-library) - - [Example](#example) - - [`useCounter.js`](#usecounterjs) - - [`useCounter.test.js`](#usecountertestjs) - - [Installation](#installation) - - [Peer Dependencies](#peer-dependencies) - - [API](#api) - - [Contributors](#contributors) - - [Issues](#issues) - - [🐛 Bugs](#-bugs) - - [💡 Feature Requests](#-feature-requests) - - [❓ Questions](#-questions) - - [LICENSE](#license) +- [The problem](#the-problem) +- [The solution](#the-solution) +- [When to use this library](#when-to-use-this-library) +- [When not to use this library](#when-not-to-use-this-library) +- [Example](#example) + - [`useCounter.js`](#usecounterjs) + - [`useCounter.test.js`](#usecountertestjs) +- [Installation](#installation) + - [Peer Dependencies](#peer-dependencies) +- [API](#api) +- [Contributors](#contributors) +- [Issues](#issues) + - [🐛 Bugs](#-bugs) + - [💡 Feature Requests](#-feature-requests) + - [❓ Questions](#-questions) +- [LICENSE](#license) From c7ee0b4879436ee7846fb49fd90b8a54ef709357 Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Tue, 8 Dec 2020 13:45:00 +1100 Subject: [PATCH 6/7] chore(test): rename test file to be consistent --- test/{resultHistory.test.js => resultHistory.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{resultHistory.test.js => resultHistory.js} (100%) diff --git a/test/resultHistory.test.js b/test/resultHistory.js similarity index 100% rename from test/resultHistory.test.js rename to test/resultHistory.js From c53b56b62302698c5c7b57a402b8b7ef1aa41c41 Mon Sep 17 00:00:00 2001 From: Michael Peyper Date: Tue, 8 Dec 2020 20:22:53 +1100 Subject: [PATCH 7/7] feat(cleanup): remove unnecessary flush microtasks as already handled by act (#511) --- src/cleanup.js | 3 --- src/flush-microtasks.js | 50 ----------------------------------------- 2 files changed, 53 deletions(-) delete mode 100644 src/flush-microtasks.js diff --git a/src/cleanup.js b/src/cleanup.js index 3699180a..d3172c46 100644 --- a/src/cleanup.js +++ b/src/cleanup.js @@ -1,9 +1,6 @@ -import flushMicroTasks from './flush-microtasks' - let cleanupCallbacks = [] async function cleanup() { - await flushMicroTasks() for (const callback of cleanupCallbacks) { await callback() } diff --git a/src/flush-microtasks.js b/src/flush-microtasks.js deleted file mode 100644 index 0869dfef..00000000 --- a/src/flush-microtasks.js +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 - * copied again from React Testing Library's flush-microtasks.js - */ - -let didWarnAboutMessageChannel = false -let 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. - const requireString = `require${Math.random()}`.slice(0, 7) - const 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.call(module, '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 = (callback) => { - const supportsMessageChannel = typeof MessageChannel === 'function' - if (supportsMessageChannel) { - const channel = new MessageChannel() - channel.port1.onmessage = callback - channel.port2.postMessage(undefined) - } else if (didWarnAboutMessageChannel === false) { - didWarnAboutMessageChannel = true - - // eslint-disable-next-line no-console - console.error( - '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.' - ) - } - } -} - -export default function flushMicroTasks() { - return { - then(resolve) { - enqueueTask(resolve) - } - } -}