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

Function createMultiDomMatcher

test/lib/next-test-utils.ts:1857–1893  ·  view source on GitHub ↗
(browser: Playwright)

Source from the content-addressed store, hash-verified

1855}
1856
1857export function createMultiDomMatcher(browser: Playwright) {
1858 /**
1859 * @param tag - tag name, e.g. 'meta'
1860 * @param queryKey - query key, e.g. 'property'
1861 * @param domAttributeField - dom attribute field, e.g. 'content'
1862 * @param expected - expected object, e.g. { description: 'my description' }
1863 * @returns {Promise<void>} - promise that resolves when the check is done
1864 *
1865 * @example
1866 * const matchMultiDom = createMultiDomMatcher(browser)
1867 * await matchMultiDom('meta', 'property', 'content', {
1868 * description: 'description',
1869 * 'og:title': 'title',
1870 * 'twitter:title': 'title'
1871 * })
1872 *
1873 */
1874 return async (
1875 tag: string,
1876 queryKey: string,
1877 domAttributeField: string,
1878 expected: Record<string, string | string[] | undefined | null>
1879 ) => {
1880 await Promise.all(
1881 Object.keys(expected).map(async (key) => {
1882 return checkMeta(
1883 browser,
1884 key,
1885 expected[key],
1886 queryKey,
1887 tag,
1888 domAttributeField
1889 )
1890 })
1891 )
1892 }
1893}
1894
1895export const checkMetaNameContentPair = (
1896 browser: Playwright,

Calls 4

checkMetaFunction · 0.85
allMethod · 0.80
keysMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected