MCPcopy
hub / github.com/vercel/next.js / check

Function check

test/lib/next-test-utils.ts:765–791  ·  view source on GitHub ↗
(
  contentFn: () => unknown | Promise<unknown>,
  regex: boolean | number | string | RegExp
)

Source from the content-addressed store, hash-verified

763 * @deprecated use retry + expect instead
764 */
765export async function check(
766 contentFn: () => unknown | Promise<unknown>,
767 regex: boolean | number | string | RegExp
768): Promise<boolean> {
769 let content: unknown
770 let lastErr: unknown
771
772 for (let tries = 0; tries < 30; tries++) {
773 try {
774 content = await contentFn()
775 if (typeof regex !== 'object') {
776 if (regex === content) {
777 return true
778 }
779 } else if (regex.test('' + content)) {
780 // found the content
781 return true
782 }
783 await waitFor(1000)
784 } catch (err) {
785 await waitFor(1000)
786 lastErr = err
787 }
788 }
789 console.error('TIMED OUT CHECK: ', { regex, content, lastErr })
790 throw new Error('TIMED OUT: ' + regex + '\n\n' + content + '\n\n' + lastErr)
791}
792
793export class File {
794 path: string

Callers 15

runTestsFunction · 0.90
runTestsFunction · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
runTestsFunction · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
lazyLoadingTestsFunction · 0.90
runTestsFunction · 0.90
index.test.tsFile · 0.90
runTestsFunction · 0.90
index.test.tsFile · 0.90

Calls 3

waitForFunction · 0.70
testMethod · 0.65
errorMethod · 0.65

Tested by 15

runTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
lazyLoadingTestsFunction · 0.72
runTestsFunction · 0.72
runTestsFunction · 0.72
checkIsReadyValuesFunction · 0.72
runTestsFunction · 0.72
checkIsReadyValuesFunction · 0.72
runTestsFunction · 0.72
showsErrorFunction · 0.72
runInvalidPagesTestsFunction · 0.72