From e6ef5af6752da53d495e1cb18b8dda752546bd03 Mon Sep 17 00:00:00 2001 From: Brian Alexis <51463930+brrianalexis@users.noreply.github.com> Date: Mon, 27 Jul 2020 15:56:12 -0300 Subject: [PATCH 1/2] Suggest using toBeEmptyDOMElement instead of toBeEmpty --- src/__tests__/to-have-text-content.js | 2 +- src/to-have-text-content.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/to-have-text-content.js b/src/__tests__/to-have-text-content.js index a8d4ef2c..b313256d 100644 --- a/src/__tests__/to-have-text-content.js +++ b/src/__tests__/to-have-text-content.js @@ -83,7 +83,7 @@ describe('.toHaveTextContent', () => { ) }) - test('when matching with empty string and element with content suggest using toBeEmpty instead', () => { + test('when matching with empty string and element with content, suggest using toBeEmptyDOMElement instead', () => { // https://github.com/testing-library/jest-dom/issues/104 const {container} = render('not empty') diff --git a/src/to-have-text-content.js b/src/to-have-text-content.js index 9c480100..1b07909b 100644 --- a/src/to-have-text-content.js +++ b/src/to-have-text-content.js @@ -25,7 +25,7 @@ export function toHaveTextContent( '', ), checkingWithEmptyString - ? `Checking with empty string will always match, use .toBeEmpty() instead` + ? `Checking with empty string will always match, use .toBeEmptyDOMElement() instead` : `Expected element ${to} have text content`, checkWith, 'Received', From 917aa6cded2ce932e251a4ed1fa1cedd2c43619f Mon Sep 17 00:00:00 2001 From: Brian Alexis <51463930+brrianalexis@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:02:00 -0300 Subject: [PATCH 2/2] fixed toBeEmptyDOMElement regular expression --- src/__tests__/to-have-text-content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/__tests__/to-have-text-content.js b/src/__tests__/to-have-text-content.js index b313256d..8874c680 100644 --- a/src/__tests__/to-have-text-content.js +++ b/src/__tests__/to-have-text-content.js @@ -89,6 +89,6 @@ describe('.toHaveTextContent', () => { expect(() => expect(container.querySelector('span')).toHaveTextContent(''), - ).toThrowError(/toBeEmpty()/) + ).toThrowError(/toBeEmptyDOMElement\(\)/) }) })