diff --git a/src/matches.ts b/src/matches.ts index 5aecb416..5e27ad3e 100644 --- a/src/matches.ts +++ b/src/matches.ts @@ -31,8 +31,10 @@ function fuzzyMatches( const normalizedText = normalizer(textToMatch) - if (typeof matcher === 'string') { - return normalizedText.toLowerCase().includes(matcher.toLowerCase()) + if (typeof matcher === 'string' || typeof matcher === 'number') { + return normalizedText + .toLowerCase() + .includes(matcher.toString().toLowerCase()) } else if (typeof matcher === 'function') { return matcher(normalizedText, node) } else { diff --git a/types/matches.d.ts b/types/matches.d.ts index 03f9a4b8..2d05d4ab 100644 --- a/types/matches.d.ts +++ b/types/matches.d.ts @@ -6,7 +6,7 @@ export type MatcherFunction = ( content: string, element: Nullish, ) => boolean -export type Matcher = MatcherFunction | RegExp | string +export type Matcher = MatcherFunction | RegExp | string | number // Get autocomplete for ARIARole union types, while still supporting another string // Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972 diff --git a/types/tsconfig.json b/types/tsconfig.json index 3c43903c..315b2549 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -1,3 +1,7 @@ { - "extends": "../tsconfig.json" + "extends": "../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "paths": {"@testing-library/dom": ["."]} + } }