MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / verifyTranslation

Function verifyTranslation

apps/site/tests/e2e/general-behavior.spec.ts:36–61  ·  view source on GitHub ↗
(page: Page, locale: Locale | string)

Source from the content-addressed store, hash-verified

34};
35
36const verifyTranslation = async (page: Page, locale: Locale | string) => {
37 // Load locale data if string code provided (e.g., 'es', 'fr')
38 const localeData: Locale =
39 typeof locale === 'string'
40 ? (
41 await import(`@node-core/website-i18n/locales/${locale}.json`, {
42 with: { type: 'json' },
43 })
44 ).default
45 : locale;
46
47 // Get navigation links and expected translations
48 const links = await page
49 .locator(locators.navLinksLocator)
50 .locator('a > span')
51 .all();
52 const expectedTexts = Object.values(
53 localeData.components.containers.navBar.links
54 );
55
56 // Verify each navigation link text matches an expected translation
57 for (const link of links) {
58 const linkText = await link.textContent();
59 expect(expectedTexts).toContain(linkText!.trim());
60 }
61};
62
63test.describe('Node.js Website', () => {
64 // Start each test from the English homepage

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected