@@ -217,11 +311,20 @@ describe('get throws a useful error message', () => {
})
test('ByTitle', () => {
- const {getByTitle} = renderResult
+ const {getByTitle} = missingRenderResult
expect(() => getByTitle('LucyRicardo')).toThrowErrorMatchingInlineSnapshot(`
Unable to find an element with the title: LucyRicardo.
+ Ignored nodes: comments, script, style
+
+ `)
+
+ expect(() => getByTitle(' LucyRicardo ')).toThrowErrorMatchingInlineSnapshot(`
+ Unable to find an element with the title: LucyRicardo (normalized from ' LucyRicardo ').
+
Ignored nodes: comments, script, style
@@ -262,12 +365,22 @@ describe('get throws a useful error message', () => {
})
test('ByDisplayValue', () => {
- const {getByDisplayValue} = renderResult
+ const {getByDisplayValue} = missingRenderResult
expect(() => getByDisplayValue('LucyRicardo'))
.toThrowErrorMatchingInlineSnapshot(`
Unable to find an element with the display value: LucyRicardo.
+ Ignored nodes: comments, script, style
+
+ `)
+
+ expect(() => getByDisplayValue(' LucyRicardo '))
+ .toThrowErrorMatchingInlineSnapshot(`
+ Unable to find an element with the display value: LucyRicardo (normalized from ' LucyRicardo ').
+
Ignored nodes: comments, script, style
@@ -311,7 +424,7 @@ describe('get throws a useful error message', () => {
})
test('ByRole', () => {
- const {getByRole} = renderResult
+ const {getByRole} = missingRenderResult
expect(() => getByRole('LucyRicardo')).toThrowErrorMatchingInlineSnapshot(`
Unable to find an accessible element with the role "LucyRicardo"
diff --git a/src/queries/display-value.ts b/src/queries/display-value.ts
index 4998a42e..75902e71 100644
--- a/src/queries/display-value.ts
+++ b/src/queries/display-value.ts
@@ -57,7 +57,7 @@ const getMissingError: GetErrorFunction<[Matcher, MatcherOptions]> = (
function getMatcherHintOrDefault(
matcher: Matcher,
- options: MatcherOptions = {},
+ options: MatcherOptions,
) {
const matcherHint = getMatcherHint(matcher, 'that its display value')
diff --git a/src/queries/placeholder-text.ts b/src/queries/placeholder-text.ts
index 089556c9..af0af50e 100644
--- a/src/queries/placeholder-text.ts
+++ b/src/queries/placeholder-text.ts
@@ -26,7 +26,7 @@ const getMissingError: GetErrorFunction<[Matcher, MatcherOptions]> = (
function getMatcherHintOrDefault(
matcher: Matcher,
- options: MatcherOptions = {},
+ options: MatcherOptions,
) {
const matcherHint = getMatcherHint(matcher, 'that its placeholder text')
diff --git a/src/queries/text.ts b/src/queries/text.ts
index a3788308..11e179cd 100644
--- a/src/queries/text.ts
+++ b/src/queries/text.ts
@@ -73,7 +73,7 @@ const getMissingError: GetErrorFunction<[Matcher, SelectorMatcherOptions]> = (
function getMatcherHintOrDefault(
matcher: Matcher,
- options: SelectorMatcherOptions = {},
+ options: SelectorMatcherOptions,
) {
const matcherHint = getMatcherHint(matcher, 'that its text')
diff --git a/src/queries/title.ts b/src/queries/title.ts
index 5660fdb9..b8c87681 100644
--- a/src/queries/title.ts
+++ b/src/queries/title.ts
@@ -50,7 +50,7 @@ const getMissingError: GetErrorFunction<[Matcher, MatcherOptions]> = (
function getMatcherHintOrDefault(
matcher: Matcher,
- options: MatcherOptions = {},
+ options: MatcherOptions,
) {
const matcherHint = getMatcherHint(matcher, 'that its title')
From 56dd0e4eabcf3b484534f479cd6fb689891291b4 Mon Sep 17 00:00:00 2001
From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com>
Date: Sun, 30 Oct 2022 01:10:07 +0300
Subject: [PATCH 6/6] format
---
src/__tests__/element-queries.js | 27 ++++++++++++++++-----------
src/queries/display-value.ts | 5 +----
src/queries/placeholder-text.ts | 5 +----
src/queries/title.ts | 5 +----
4 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/src/__tests__/element-queries.js b/src/__tests__/element-queries.js
index 66788486..ba282664 100644
--- a/src/__tests__/element-queries.js
+++ b/src/__tests__/element-queries.js
@@ -29,7 +29,7 @@ test('query can return null', () => {
})
describe('get throws a useful error message', () => {
- let missingRenderResult;
+ let missingRenderResult
beforeEach(() => {
missingRenderResult = render(
@@ -114,7 +114,8 @@ describe('get throws a useful error message', () => {
test('Missing element', () => {
const {getByText} = missingRenderResult
- expect(() => getByText('LucyRicardo')).toThrowErrorMatchingInlineSnapshot(`
+ expect(() => getByText('LucyRicardo'))
+ .toThrowErrorMatchingInlineSnapshot(`
Unable to find an element with the text: LucyRicardo. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
Ignored nodes: comments, script, style
@@ -133,7 +134,8 @@ describe('get throws a useful error message', () => {
`)
- expect(() => getByText(' LucyRicardo ', {})).toThrowErrorMatchingInlineSnapshot(`
+ expect(() => getByText(' LucyRicardo ', {}))
+ .toThrowErrorMatchingInlineSnapshot(`
Unable to find an element with the text: LucyRicardo (normalized from ' LucyRicardo '). This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
Ignored nodes: comments, script, style
@@ -142,7 +144,8 @@ describe('get throws a useful error message', () => {
`)
- expect(() => getByText(/LucyRicardo/)).toThrowErrorMatchingInlineSnapshot(`
+ expect(() => getByText(/LucyRicardo/))
+ .toThrowErrorMatchingInlineSnapshot(`
Unable to find an element that its text match the regex: /LucyRicardo/. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
Ignored nodes: comments, script, style
@@ -173,14 +176,15 @@ describe('get throws a useful error message', () => {