Skip to content

Commit b12cb29

Browse files
committed
simplify conditional
1 parent e69fd6b commit b12cb29

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/queries/test-id.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ const getMissingError = (
1818
{computeCloseMatches = false, ...options} = {},
1919
) => {
2020
const defaultMessage = `Unable to find an element by: [${getTestIdAttribute()}="${id}"]`
21-
if (!computeCloseMatches || typeof id !== 'string') {
22-
return defaultMessage
23-
}
24-
25-
const closeMatches = getCloseMatchesByAttribute(
26-
getTestIdAttribute(),
27-
c,
28-
id,
29-
options,
30-
)
21+
22+
const closeMatches =
23+
!computeCloseMatches || typeof id !== 'string'
24+
? []
25+
: getCloseMatchesByAttribute(getTestIdAttribute(), c, id, options)
26+
3127
return closeMatches.length === 0
3228
? defaultMessage
3329
: `${defaultMessage}. Did you mean one of the following?\n${closeMatches.join(

0 commit comments

Comments
 (0)