Skip to content

ParaglideJS: How to use it in test frameworks ? #2035

Discussion options

You must be logged in to vote

Likely the import alias $paraglide isn't set up to work in test-files. try importing from src/paraglide/messages.js instead.

Also keep in mind that the test-browser and the Playwright test run in different processes, so the language will not automatically be shared between them. I would recommend always explicitly setting the language for messages that are used in a test.

Try

import { expect, test } from '@playwright/test';
import * as m from '../paraglide/messages';

test('index page has expected h1', async ({ page }) => {
	await page.goto('/');
	await expect(page.getByRole('heading', { name: m.page_hello_title({} , { languageTag: "en" }) })).toBeVisible();
});

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@samuelstroschein
Comment options

@LBF38
Comment options

@LorisSigrist
Comment options

Answer selected by LBF38
@LBF38
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants