@@ -406,16 +406,23 @@ export class HarnessPredicate<T extends ComponentHarness> {
406406 }
407407
408408 /**
409- * Checks if a string matches the given pattern.
410- * @param s The string to check, or a Promise for the string to check.
411- * @param pattern The pattern the string is expected to match. If `pattern` is a string, `s` is
412- * expected to match exactly. If `pattern` is a regex, a partial match is allowed.
413- * @return A Promise that resolves to whether the string matches the pattern.
409+ * Checks if the specified nullable string value matches the given pattern.
410+ * @param value The nullable string value to check, or a Promise resolving to the
411+ * nullable string value.
412+ * @param pattern The pattern the value is expected to match. If `pattern` is a string,
413+ * `value` is expected to match exactly. If `pattern` is a regex, a partial match is
414+ * allowed. If `pattern` is `null`, the value is expected to be `null`.
415+ * @return A Promise that resolves to whether the value matches the pattern.
414416 */
415- static async stringMatches ( s : string | Promise < string > , pattern : string | RegExp ) :
416- Promise < boolean > {
417- s = await s ;
418- return typeof pattern === 'string' ? s === pattern : pattern . test ( s ) ;
417+ static async stringMatches ( value : string | null | Promise < string | null > ,
418+ pattern : string | RegExp | null ) : Promise < boolean > {
419+ value = await value ;
420+ if ( pattern === null ) {
421+ return value === null ;
422+ } else if ( value === null ) {
423+ return false ;
424+ }
425+ return typeof pattern === 'string' ? value === pattern : pattern . test ( value ) ;
419426 }
420427
421428 /**
0 commit comments