Go to file
Younes Jaaidi 2aa4597597 Add support for Angular 17 (#5)
* feat(ct): angular component testing

* test(ct): test non-event-emitter outputs

* test(ct): test output listener replacement

* feat(ct): support non-event-emitter outputs

* docs(ct): angular

* fix(ct): angular source maps

* chore(ct): new angular logo

* refactor(ct-angular): bump to Angular 17 and move out analogjs plugin

Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>

* refactor(ct-angular): fix component resolution by temporary removing analogjs plugin

Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>

* refactor(ct-angular): fix mount

Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>

* refactor(ct-angular): disable analog plugin as it breaks component registration

* refactor(ct-angular): fix input forwarding

* refactor(ct-angular): fix angular outputs

* refactor(ct-angular): fix angular slots

* test(ct-angular): fix all tests

* test(ct-angular): fix all angular tests

* test(ct-angular): use analog's vite plugin to handle template files

* refactor(ct-angular): remove router-specific code

* refactor(ct-angular): clean up dependencies

* refactor(ct-angular): remove compiler import

* refactor(ct-angular): fix vite version mismatch in tests

* refactor(ct-angular): bump @playwright/experimental-ct-angular to 1.42.0-next

* test(ct-angular): add tests for template rendering

* feat(ct-angular): render simple template

* feat(ct-angular): render template with child components

* feat(ct-angular): render component with signal inputs

* test(ct-angular): make input required

* test(ct-angular): remove now useless import

* feat(ct-angular): allow setting providers

* refactor(ct-angular): clean up slots remains

* feat(ct): angular component testing

* test(ct): test non-event-emitter outputs

* test(ct): test output listener replacement

* feat(ct): support non-event-emitter outputs

* fix(ct): angular source maps

* docs(ct): angular

* chore(ct): new angular logo

* feat(ct-angular): add pw-angular bin

* test(ct-angular): fix type check

use strict dependencies versions to reduce unpredictable behavior as package-lock.json is gitignored

* refactor(ct-angular): remove useless NODE_ENV=test

as we are setting the tsconfig manually
Cf. https://github.com/sand4rt/playwright/pull/5#discussion_r1541172952

* refactor(ct-angular): use playwright.config.mts as analog vite plugin is esm only

* chore(ct-angular): lint

* fix(ct-angular): resolve Angular component usages

* fix(ct-angular): resolve Angular imports/providers usages

* test(ct-angular): test url change

* test(ct-angular): remove duplicate test

* chore(ct-angular): remove useless pw-angular cli

* chore(ct-angular): remove duplicate PlaywrightTestConfig type

* feat(ct-angular): export the right types

* chore(ct-angular): tidy up

* feat(ct-angular): throw an explicit error when mounting JSX

* chore(ct-angular): remove vite from devDependencies as not used anymore

* chore(ct-angular): remove useless skipLibCheck flag

* chore(ct-angular): remove useless @angular/compiler

Angular's esbuild plugin will automatically add it in jit mode anyway.
Users who really want to use another plugin that requires it can still add it manually to their playwright/index.ts.

* test(ct-angular): improve output listener update test

* chore(ct): revert adapters imports and template

---------

Co-authored-by: sand4rt <info@mesander.com>
Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>
2024-05-07 22:29:31 +02:00
.devcontainer chore: fixed devcontainer Docker usage (#3898) 2020-09-17 11:21:10 -07:00
.github devops: remove Node.js 16 bots (#30683) 2024-05-06 22:52:31 +00:00
browser_patches chore: update playwright-browsers to Mar 19 (#30599) 2024-04-29 17:03:40 -07:00
docs/src docs(ct): angular 2024-05-07 22:29:31 +02:00
examples chore: mark server-related fixture options as such (#29602) 2024-02-21 17:04:36 -08:00
packages Add support for Angular 17 (#5) 2024-05-07 22:29:31 +02:00
tests Add support for Angular 17 (#5) 2024-05-07 22:29:31 +02:00
utils feat(ct): angular component testing 2024-05-07 22:29:31 +02:00
.editorconfig Initial commit 2019-11-19 10:58:15 -08:00
.eslintignore fix(types): allow any return type from event handlers (#30492) 2024-04-24 09:25:43 -07:00
.eslintrc-with-ts-config.js chore: strengthen linting (#29669) 2024-02-26 16:52:28 -08:00
.eslintrc.js chore: strengthen linting (#29669) 2024-02-26 16:52:28 -08:00
.gitattributes feat: implement a new image comparison function (#19166) 2022-12-02 15:22:05 -08:00
.gitignore devops: change flakiness-dashboard auth to be secret-less (#30488) 2024-04-24 22:23:28 +02:00
babel.config.json chore: move off babel proposals to plugins (#29053) 2024-01-18 17:50:52 -08:00
CODE_OF_CONDUCT.md Revert "chore: rework the crlf in md fix" 2021-01-20 15:45:59 -08:00
CONTRIBUTING.md docs(contributing): update required node version (#29547) 2024-02-19 09:28:49 +01:00
LICENSE chore(license): use Apache 2.0 (#389) 2020-01-06 18:22:35 -08:00
NOTICE chore(license): add NOTICE (#309) 2019-12-19 12:19:54 -08:00
package-lock.json Add support for Angular 17 (#5) 2024-05-07 22:29:31 +02:00
package.json chore: mark 1.45.0-next (#30598) 2024-04-29 17:19:05 -07:00
README.md feat(chromium): roll to r1117 (#30646) 2024-05-03 15:29:02 +00:00
SECURITY.md Revert "chore: rework the crlf in md fix" 2021-01-20 15:45:59 -08:00
tsconfig.json chore: enable eslint for js (#29639) 2024-02-26 09:39:21 -08:00

🎭 Playwright

npm version Chromium version Firefox version WebKit version

Documentation | API reference

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

Linux macOS Windows
Chromium 125.0.6422.26
WebKit 17.4
Firefox 125.0.1

Headless execution is supported for all browsers on all platforms. Check out system requirements for details.

Looking for Playwright for Python, .NET, or Java?

Installation

Playwright has its own test runner for end-to-end tests, we call it Playwright Test.

Using init command

The easiest way to get started with Playwright Test is to run the init command.

# Run from your project's root directory
npm init playwright@latest
# Or create a new project
npm init playwright@latest new-project

This will create a configuration file, optionally add examples, a GitHub Action workflow and a first test example.spec.ts. You can now jump directly to writing assertions section.

Manually

Add dependency and install browsers.

npm i -D @playwright/test
# install supported browsers
npx playwright install

You can optionally install only selected browsers, see install browsers for more details. Or you can install no browsers at all and use existing browser channels.

Capabilities

Resilient • No flaky tests

Auto-wait. Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts - a primary cause of flaky tests.

Web-first assertions. Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met.

Tracing. Configure test retry strategy, capture execution trace, videos and screenshots to eliminate flakes.

No trade-offs • No limits

Browsers run web content belonging to different origins in different processes. Playwright is aligned with the architecture of the modern browsers and runs tests out-of-process. This makes Playwright free of the typical in-process test runner limitations.

Multiple everything. Test scenarios that span multiple tabs, multiple origins and multiple users. Create scenarios with different contexts for different users and run them against your server, all in one test.

Trusted events. Hover elements, interact with dynamic controls and produce trusted events. Playwright uses real browser input pipeline indistinguishable from the real user.

Test frames, pierce Shadow DOM. Playwright selectors pierce shadow DOM and allow entering frames seamlessly.

Full isolation • Fast execution

Browser contexts. Playwright creates a browser context for each test. Browser context is equivalent to a brand new browser profile. This delivers full test isolation with zero overhead. Creating a new browser context only takes a handful of milliseconds.

Log in once. Save the authentication state of the context and reuse it in all the tests. This bypasses repetitive log-in operations in each test, yet delivers full isolation of independent tests.

Powerful Tooling

Codegen. Generate tests by recording your actions. Save them into any language.

Playwright inspector. Inspect page, generate selectors, step through the test execution, see click points and explore execution logs.

Trace Viewer. Capture all the information to investigate the test failure. Playwright trace contains test execution screencast, live DOM snapshots, action explorer, test source and many more.

Looking for Playwright for TypeScript, JavaScript, Python, .NET, or Java?

Examples

To learn how to run these Playwright Test examples, check out our getting started docs.

Page screenshot

This code snippet navigates to Playwright homepage and saves a screenshot.

import { test } from '@playwright/test';

test('Page Screenshot', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.screenshot({ path: `example.png` });
});

Mobile and geolocation

This snippet emulates Mobile Safari on a device at given geolocation, navigates to maps.google.com, performs the action and takes a screenshot.

import { test, devices } from '@playwright/test';

test.use({
  ...devices['iPhone 13 Pro'],
  locale: 'en-US',
  geolocation: { longitude: 12.492507, latitude: 41.889938 },
  permissions: ['geolocation'],
})

test('Mobile and geolocation', async ({ page }) => {
  await page.goto('https://maps.google.com');
  await page.getByText('Your location').click();
  await page.waitForRequest(/.*preview\/pwa/);
  await page.screenshot({ path: 'colosseum-iphone.png' });
});

Evaluate in browser context

This code snippet navigates to example.com, and executes a script in the page context.

import { test } from '@playwright/test';

test('Evaluate in browser context', async ({ page }) => {
  await page.goto('https://www.example.com/');
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio
    }
  });
  console.log(dimensions);
});

Intercept network requests

This code snippet sets up request routing for a page to log all network requests.

import { test } from '@playwright/test';

test('Intercept network requests', async ({ page }) => {
  // Log and continue all network requests
  await page.route('**', route => {
    console.log(route.request().url());
    route.continue();
  });
  await page.goto('http://todomvc.com');
});

Resources