@@ -1522,3 +1522,41 @@ export async function toggleCollapseCallStackFrames(browser: BrowserInterface) {
15221522 expect ( currExpanded ) . not . toBe ( lastExpanded )
15231523 } )
15241524}
1525+
1526+ /**
1527+ * Encodes the params into a URLSearchParams object using the format that the
1528+ * now builder uses for route matches (adding the `nxtP` prefix to the keys).
1529+ *
1530+ * @param params - The params to encode.
1531+ * @param extraQueryParams - The extra query params to encode (without the `nxtP` prefix).
1532+ * @returns The encoded URLSearchParams object.
1533+ */
1534+ export function createNowRouteMatches (
1535+ params : Record < string , string > ,
1536+ extraQueryParams : Record < string , string > = { }
1537+ ) : URLSearchParams {
1538+ const urlSearchParams = new URLSearchParams ( )
1539+ for ( const [ key , value ] of Object . entries ( params ) ) {
1540+ urlSearchParams . append ( `nxtP${ key } ` , value )
1541+ }
1542+ for ( const [ key , value ] of Object . entries ( extraQueryParams ) ) {
1543+ urlSearchParams . append ( key , value )
1544+ }
1545+
1546+ return urlSearchParams
1547+ }
1548+
1549+ export async function assertNoConsoleErrors ( browser : BrowserInterface ) {
1550+ const logs = await browser . log ( )
1551+ const warningsAndErrors = logs . filter ( ( log ) => {
1552+ return (
1553+ log . source === 'warning' ||
1554+ ( log . source === 'error' &&
1555+ // These are expected when we visit 404 pages.
1556+ log . message !==
1557+ 'Failed to load resource: the server responded with a status of 404 (Not Found)' )
1558+ )
1559+ } )
1560+
1561+ expect ( warningsAndErrors ) . toEqual ( [ ] )
1562+ }
0 commit comments