Can I write my Playwright scripts in TypeScript?
Yes. Loadster Playwright scripts support both JavaScript and TypeScript, whichever you prefer. Loadster runs your script through the Playwright Test runner, which compiles TypeScript automatically—so type annotations, interfaces, and other TypeScript features work out of the box with no extra configuration.
import {test, expect, type Page} from '@playwright/test';
interface Credentials {
username: string;
password: string;
}
test('login with typed credentials', async ({page}: {page: Page}) => {
const creds: Credentials = {username: 'demo', password: 'secret'};
await page.goto('https://example.com/login');
await page.fill('#username', creds.username);
await page.fill('#password', creds.password);
await page.click('button[type="submit"]');
});
You can paste an existing .ts or .js Playwright test straight into the script editor—there’s nothing extra to
configure either way. See Playwright Scripting for more on writing and playing Playwright
scripts.