Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Conversation

@jrolfs
Copy link
Member

@jrolfs jrolfs commented Jul 8, 2022

Implement configure API for locator-based queries via test.use.

Global

// playwright.config.ts
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  use: {
    testIdAttribute: 'data-custom-test-id',
    asyncUtilsTimeout: 5000,
  },
};

export default config;

Local

import { test as baseTest } from '@playwright/test'
import {
  locatorFixtures as fixtures,
  LocatorFixtures as TestingLibraryFixtures,
  within
} from '@playwright-testing-library/test/fixture';

const test = baseTest.extend<TestingLibraryFixtures>(fixtures);

const {expect} = test;

// Entire test suite
test.use({ testIdAttribute: 'data-custom-test-id' });

test.describe(() => {
  // Specific block
  test.use({
    testIdAttribute: 'some-other-test-id',
    asyncUtilsTimeout: 5000,
  });

  test('my form', async ({queries: {getByTestId}}) => {
    // ...
  });
});

@jrolfs jrolfs self-assigned this Jul 8, 2022
@jrolfs jrolfs force-pushed the feature/locator-configure branch from 2db6714 to ac197d4 Compare July 8, 2022 21:08
@jrolfs jrolfs force-pushed the feature/locator-configure branch 2 times, most recently from 778917c to 79af54f Compare August 26, 2022 07:28
@jrolfs jrolfs marked this pull request as ready for review August 26, 2022 07:28
@jrolfs jrolfs requested a review from sebinsua August 26, 2022 07:30
@jrolfs jrolfs force-pushed the feature/locator-configure branch from 79af54f to 4f4d57e Compare August 26, 2022 19:41
jrolfs added 2 commits August 26, 2022 12:48
### Global

```ts
// playwright.config.ts
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  use: {
    testIdAttribute: 'data-custom-test-id',
    asyncUtilsTimeout: 5000,
  },
};

export default config;
```

### Local

```ts
import { test as baseTest } from '@playwright/test'
import {
  locatorFixtures as fixtures,
  LocatorFixtures as TestingLibraryFixtures,
  within
} from '@playwright-testing-library/test/fixture';

const test = baseTest.extend<TestingLibraryFixtures>(fixtures);

const {expect} = test;

// Entire test suite
test.use({ testIdAttribute: 'data-custom-test-id' });

test.describe(() => {
  // Specific block
  test.use({
    testIdAttribute: 'some-other-test-id',
    asyncUtilsTimeout: 5000,
  });

  test('my form', async ({queries: {getByTestId}}) => {
    // ...
  });
});
```
@jrolfs jrolfs force-pushed the feature/locator-configure branch from 4f4d57e to 625dbce Compare August 26, 2022 19:54
@jrolfs jrolfs merged commit 375a6a9 into beta Aug 26, 2022
@jrolfs jrolfs deleted the feature/locator-configure branch August 26, 2022 20:06
@github-actions
Copy link

🎉 This PR is included in version 4.4.0-beta.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant