4.41.24 • Published 5 days ago

@tramvai/test-pw v4.41.24

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 days ago

Tramvai test Playwright

Set of helpers for using playwright in the integration tests

Playwright should be installed separately

Installation

npm install --save-dev @tramvai/test-pw

Usage

Configuration

Create file playwright.config.ts with defaults from @tramvai/test-pw package:

import { createPlaywrightConfig } from '@tramvai/test-pw';

export default createPlaywrightConfig();

You can always extend default config, here is createPlaywrightConfig type definition:

// passed configuration object will be merged with defaults
type createPlaywrightConfig = (config: PlaywrightTestConfig) => PlaywrightTestConfig;

Testing

:::tip

Use case for this section and startAppFixture - monorepo with many tramvai modules and example applications, where you need to test independent features.

All usage of startAppFixture in different workers will run development build, which might not be optimal for tests execution time, if you want to test the same app in different cases.

For real applications, prefer to run application once as web server or manually and pass baseUrl after.

:::

@tramvai/test-pw provide a useful fixture for application start (local server in development mode) and testing - startAppFixture. This fixture use startCli method from @tramvai/test-integration package.

First, you need to add and configure this fixture for application tests:

import path from 'path';
import { test as base } from '@playwright/test';
import type { StartAppTypes } from '@tramvai/test-pw';
import { startAppFixture } from '@tramvai/test-pw';

type TestFixture = {};

type WorkerFixture = {
  app: StartAppTypes.TestApp;
  appTarget: StartAppTypes.AppTarget;
  startOptions: StartAppTypes.StartOptions;
};

export const test = base.extend<TestFixture, WorkerFixture>({
  appTarget: [
    // provide application name and directory
    {
      target: 'appName',
      cwd: path.resolve(__dirname, '..'),
    },
    { scope: 'worker', auto: true, option: true },
  ],
  // any `startCli` parameters
  startOptions: [{
    env: {
      SOME_MOCKED_API: 'xxx'
    },
  }, { scope: 'worker', auto: true, option: true }],

  app: startAppFixture,
});

Then, use the app object in integration tests:

import { expect } from '@playwright/test';
import { test } from './test-fixture';

test.describe('examples/app', async () => {
  test('Navigation is visible', async ({ app, page }) => {
    await page.goto(app.serverUrl);

    expect(page.getByRole('navigation')).toBeVisible();
  });
});

You can find more info about app object in our Testing Guide

Production build testing

If you need to test production build, @tramvai/test-pw provide a few fixtures for it:

  • appServerFixture to run compiled application server
  • buildAppFixture to run production build of the application (will be called implicitly for appServerFixture)

First, configure fixtures:

import path from 'path';
import { test as base } from '@playwright/test';
import type { BuildAppTypes } from '@tramvai/test-pw';
import { appServerFixture } from '@tramvai/test-pw';

type TestFixture = {};

type WorkerFixture = {
  app: BuildAppTypes.TestApp;
  appTarget: BuildAppTypes.AppTarget;
  buildOptions: BuildAppTypes.StartOptions;
};

export const test = base.extend<TestFixture, WorkerFixture>({
  appTarget: [
    // provide application name and directory
    {
      target: 'appName',
      cwd: path.resolve(__dirname, '..'),
    },
    { scope: 'worker', auto: true, option: true },
  ],
  // any `buildCli` parameters
  buildOptions: [{
    env: {
      SOME_MOCKED_API: 'xxx'
    },
  }, { scope: 'worker', auto: true, option: true }],

  appServer: appServerFixture,
});

Then, use the appServer object in integration tests:

import { expect } from '@playwright/test';
import { test } from './test-fixture';

test.describe('examples/app', async () => {
  test('Navigation is visible', async ({ appServer, page }) => {
    await page.goto(`http://localhost:${appServer.port}/`);

    expect(page.getByRole('navigation')).toBeVisible();
  });
});
3.41.38

10 days ago

4.41.24

5 days ago

4.41.22

8 days ago

4.41.21

10 days ago

5.5.4

10 days ago

5.6.2

5 days ago

5.6.0

8 days ago

4.41.17

19 days ago

4.41.19

16 days ago

3.41.36

19 days ago

5.5.2

16 days ago

5.5.1

19 days ago

4.41.15

26 days ago

4.41.14

30 days ago

5.4.3

26 days ago

5.4.2

30 days ago

3.41.35

30 days ago

4.41.11

1 month ago

5.4.0

1 month ago

4.41.8

1 month ago

5.1.2

1 month ago

4.41.7

1 month ago

5.0.2

1 month ago

5.1.1

1 month ago

5.1.0

1 month ago

4.41.2

2 months ago

4.41.1

2 months ago

4.41.6

1 month ago

4.41.5

1 month ago

4.41.4

1 month ago

4.41.3

2 months ago

3.41.33

1 month ago

3.41.32

1 month ago

3.41.31

2 months ago

3.41.30

2 months ago

4.37.0

2 months ago

4.40.3

2 months ago

4.40.1

2 months ago

4.40.5

2 months ago

4.36.2

2 months ago

4.36.0

2 months ago

4.39.1

2 months ago

4.39.0

2 months ago

4.38.0

2 months ago

3.41.19

2 months ago

3.41.16

3 months ago

3.41.13

3 months ago

3.41.11

3 months ago

4.33.3

3 months ago

3.41.26

2 months ago

3.41.24

2 months ago

3.41.22

2 months ago

4.35.0

3 months ago

4.34.4

3 months ago

4.34.1

3 months ago

4.33.2

3 months ago

4.33.1

3 months ago

3.41.9

3 months ago

4.32.6

3 months ago

4.32.5

3 months ago

3.41.4

3 months ago

3.41.5

3 months ago

3.41.6

3 months ago

3.41.7

3 months ago

4.25.0

4 months ago

4.26.4

4 months ago

4.26.5

4 months ago

4.26.7

4 months ago

4.26.0

4 months ago

4.26.1

4 months ago

4.26.2

4 months ago

4.26.9

3 months ago

4.14.0

6 months ago

4.24.0

4 months ago

4.24.1

4 months ago

4.13.0

6 months ago

4.20.7

4 months ago

4.20.9

4 months ago

4.31.0

3 months ago

3.40.76

3 months ago

3.40.73

3 months ago

3.40.70

3 months ago

4.27.1

3 months ago

4.18.1

5 months ago

4.18.3

5 months ago

4.18.4

5 months ago

4.18.0

5 months ago

4.18.5

5 months ago

3.40.49

5 months ago

3.40.48

5 months ago

3.40.47

5 months ago

3.40.46

5 months ago

3.40.44

5 months ago

3.40.43

5 months ago

4.21.0

4 months ago

4.17.0

5 months ago

3.40.69

3 months ago

3.40.67

4 months ago

3.40.65

4 months ago

3.40.62

4 months ago

3.40.61

4 months ago

3.40.60

4 months ago

4.20.1

4 months ago

4.29.1

3 months ago

3.40.58

4 months ago

3.40.57

4 months ago

4.32.0

3 months ago

3.40.53

4 months ago

3.40.51

4 months ago

4.32.2

3 months ago

3.41.0

3 months ago

3.41.1

3 months ago

3.41.3

3 months ago

4.12.5

6 months ago

4.23.0

4 months ago

4.19.0

5 months ago

4.19.2

5 months ago

4.19.3

5 months ago

4.19.4

5 months ago

4.19.5

4 months ago

4.22.0

4 months ago

4.12.4

6 months ago

4.12.2

6 months ago

3.40.33

6 months ago

3.40.32

6 months ago

4.11.1

6 months ago

4.11.2

6 months ago

4.10.1

6 months ago

3.40.30

6 months ago

4.9.1

6 months ago

4.9.0

7 months ago

4.8.6

7 months ago

3.40.28

7 months ago

4.8.4

7 months ago

4.8.3

7 months ago

3.40.26

7 months ago

3.40.25

7 months ago

4.7.1

7 months ago

3.40.21

7 months ago

4.7.0

7 months ago

3.40.20

7 months ago

4.4.6

7 months ago

3.40.17

7 months ago

4.4.5

7 months ago

4.4.4

7 months ago

3.40.16

7 months ago

4.4.1

7 months ago

4.4.3

7 months ago

3.40.14

7 months ago

3.40.13

7 months ago

4.3.1

7 months ago

3.40.11

7 months ago

4.3.0

7 months ago

3.40.6

7 months ago

3.40.7

7 months ago

4.2.1

7 months ago

4.2.0

7 months ago

4.1.0

7 months ago

4.0.6

7 months ago

3.40.5

7 months ago

4.0.5

8 months ago

4.0.4

8 months ago

3.40.4

8 months ago

3.38.0

8 months ago

3.37.10

8 months ago

3.37.8

8 months ago

3.37.7

8 months ago

3.37.5

8 months ago

3.37.1

9 months ago

3.34.0

9 months ago

3.33.2

9 months ago

3.33.0

9 months ago

3.32.3

10 months ago

3.31.0

10 months ago

3.31.2

10 months ago

3.31.3

10 months ago

3.30.1

10 months ago

3.27.5

10 months ago

3.27.3

10 months ago

3.27.4

10 months ago

3.27.0

10 months ago

3.26.3

10 months ago

3.26.2

10 months ago

3.25.5

10 months ago

3.25.6

10 months ago

3.25.3

10 months ago

3.25.2

10 months ago

3.24.3

11 months ago

3.25.0

11 months ago

3.24.1

11 months ago

3.24.0

11 months ago

3.23.0

11 months ago

3.21.0

11 months ago

3.19.0

11 months ago

3.19.1

11 months ago

3.17.0

12 months ago

3.12.0

12 months ago

3.14.1

12 months ago

3.14.0

12 months ago

2.160.25

12 months ago

3.13.0

12 months ago

3.15.1

12 months ago

3.10.2

12 months ago

3.16.0

12 months ago

3.11.0

12 months ago

2.123.4

1 year ago

2.146.1

1 year ago

2.123.3

1 year ago

2.123.2

1 year ago

2.123.1

1 year ago

2.146.0

1 year ago

2.142.1

1 year ago

2.142.0

1 year ago

2.139.3

1 year ago

2.139.2

1 year ago

3.2.0

1 year ago

2.154.0

1 year ago

2.150.0

1 year ago

2.150.1

1 year ago

2.149.0

1 year ago

2.149.1

1 year ago

2.145.0

1 year ago

2.145.1

1 year ago

2.160.4

1 year ago

2.141.2

1 year ago

2.122.0

1 year ago

2.141.1

1 year ago

2.160.2

1 year ago

2.160.1

1 year ago

2.119.5

1 year ago

2.119.4

1 year ago

2.119.3

1 year ago

2.119.2

1 year ago

2.119.0

1 year ago

2.130.9

1 year ago

2.130.7

1 year ago

2.130.6

1 year ago

2.153.3

1 year ago

2.160.21

12 months ago

3.5.0

1 year ago

2.134.0

1 year ago

2.130.4

1 year ago

2.153.1

1 year ago

2.153.2

1 year ago

2.153.0

1 year ago

2.160.12

1 year ago

2.160.17

12 months ago

2.160.19

12 months ago

2.125.4

1 year ago

2.148.1

1 year ago

2.125.3

1 year ago

2.125.2

1 year ago

2.148.0

1 year ago

2.125.0

1 year ago

2.160.10

1 year ago

2.121.2

1 year ago

3.9.1

12 months ago

3.9.0

12 months ago

2.118.1

1 year ago

3.0.2

1 year ago

2.133.5

1 year ago

2.133.4

1 year ago

3.10.0

12 months ago

2.137.0

1 year ago

2.133.2

1 year ago

3.4.1

1 year ago

2.156.1

1 year ago

2.152.2

1 year ago

2.133.0

1 year ago

2.152.3

1 year ago

2.152.1

1 year ago

3.0.0

1 year ago

2.147.1

1 year ago

2.124.0

1 year ago

2.143.0

1 year ago

2.143.1

1 year ago

2.120.0

1 year ago

2.130.10

1 year ago

3.4.6

1 year ago

3.4.5

1 year ago

2.159.5

1 year ago

2.117.4

1 year ago

2.159.6

1 year ago

2.130.11

1 year ago

2.117.2

1 year ago

2.159.4

1 year ago

2.159.1

1 year ago

2.117.0

1 year ago

2.159.2

1 year ago

3.7.0

12 months ago

3.3.2

1 year ago

2.132.1

1 year ago

2.155.0

1 year ago

2.132.0

1 year ago

2.151.0

1 year ago

2.112.0

1 year ago

2.111.1

1 year ago

2.111.0

1 year ago

2.108.1

1 year ago

2.106.3

1 year ago

2.106.4

1 year ago

2.106.5

1 year ago

2.95.0

2 years ago

2.97.2

2 years ago

2.95.4

2 years ago

2.97.0

2 years ago

2.101.0

2 years ago

2.101.1

2 years ago

2.103.1

2 years ago

2.105.0

1 year ago

2.109.0

1 year ago

2.109.1

1 year ago

2.98.2

2 years ago

2.110.0

1 year ago

2.98.0

2 years ago

2.94.27

2 years ago

2.94.24

2 years ago

2.94.23

2 years ago

2.100.0

2 years ago

2.94.25

2 years ago

2.102.1

2 years ago

2.104.0

1 year ago

2.104.2

1 year ago

2.104.3

1 year ago

2.108.0

1 year ago

2.106.2

1 year ago

2.104.4

1 year ago

2.94.17

2 years ago

2.94.16

2 years ago

2.94.2

2 years ago

2.94.19

2 years ago

2.94.18

2 years ago

2.94.13

2 years ago

2.94.12

2 years ago

2.94.6

2 years ago

2.94.15

2 years ago

2.94.4

2 years ago

2.94.9

2 years ago

2.94.7

2 years ago

2.94.8

2 years ago

2.89.2

2 years ago

2.93.0

2 years ago

2.92.1

2 years ago

2.94.0

2 years ago

2.76.2

2 years ago

2.77.0

2 years ago

2.92.0

2 years ago

2.91.1

2 years ago

2.90.0

2 years ago

2.79.9

2 years ago

2.78.2

2 years ago

2.78.1

2 years ago

2.79.7

2 years ago

2.79.6

2 years ago

2.79.5

2 years ago

2.79.4

2 years ago

2.84.0

2 years ago

2.82.0

2 years ago

2.87.0

2 years ago

2.85.1

2 years ago

2.84.2

2 years ago

2.74.0

2 years ago

2.73.1

2 years ago

2.73.0

2 years ago

2.75.0

2 years ago

2.67.1

2 years ago

2.72.0

2 years ago

2.70.1

2 years ago

2.72.5

2 years ago

2.72.4

2 years ago

2.72.3

2 years ago

2.70.0

2 years ago

2.65.9

2 years ago

2.66.2

2 years ago

2.66.3

2 years ago

2.66.0

2 years ago

2.67.0

2 years ago

2.64.0

2 years ago

2.63.0

2 years ago

2.61.2

2 years ago

2.61.1

2 years ago

2.59.4

2 years ago

2.59.3

2 years ago

2.59.2

2 years ago

2.59.0

2 years ago