Angular
Quick glance
Better code than words, here is a simple example of an Angular Testronaut test:
import { expect, test } from '@testronaut/angular';
import { mount } from '@testronaut/angular/browser';
import { SpaceshipLauncher } from './spaceship-launcher';
test('take off', async ({ inPage, page }) => {
await inPage(() => mount(SpaceshipLauncher));
await page.getByRole('button', { name: 'Take off' }).click();
await expect(page.getByRole('status')).toHaveText('Spaceship launched!');
});
This test will work just like any other Playwright test, but the SpaceshipLauncher component will be mounted in the browser.
Setup
- Angular CLI
- Nx
npm exec ng add @testronaut/angular
npm exec nx add @testronaut/angular
Run the tests
npm exec playwright test -c playwright-testronaut.config.mts