(page: Page, lang: string)
| 63 | export const sourceLocale = langTranslations[0].lang; |
| 64 | |
| 65 | export async function browserCheck(page: Page, lang: string) { |
| 66 | const translation = langTranslations.find((t) => t.lang === lang)?.translation; |
| 67 | if (!translation) { |
| 68 | throw new Error(`Could not find translation for language '${lang}'`); |
| 69 | } |
| 70 | |
| 71 | const getParagraph = async (id: string) => page.$eval(`p#${id}`, (el) => el.textContent?.trim()); |
| 72 | |
| 73 | const hello = await getParagraph('hello'); |
| 74 | if (hello !== translation.hello) { |
| 75 | throw new Error(`Expected 'hello' to be '${translation.hello}', but got '${hello}'.`); |
| 76 | } |
| 77 | |
| 78 | const locale = await getParagraph('locale'); |
| 79 | if (locale !== lang) { |
| 80 | throw new Error(`Expected 'locale' to be '${lang}', but got '${locale}'.`); |
| 81 | } |
| 82 | |
| 83 | const date = await getParagraph('date'); |
| 84 | if (date !== translation.date) { |
| 85 | throw new Error(`Expected 'date' to be '${translation.date}', but got '${date}'.`); |
| 86 | } |
| 87 | |
| 88 | const plural = await getParagraph('plural'); |
| 89 | if (plural !== translation.plural) { |
| 90 | throw new Error(`Expected 'plural' to be '${translation.plural}', but got '${plural}'.`); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export interface ExternalServer { |
| 95 | readonly server: Server; |
no test coverage detected