Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: testIdAttribute via config does not take effect in globalSetup function #30605

Closed
dcaldastp opened this issue Apr 30, 2024 · 1 comment · Fixed by #30609
Closed

[Bug]: testIdAttribute via config does not take effect in globalSetup function #30605

dcaldastp opened this issue Apr 30, 2024 · 1 comment · Fixed by #30609

Comments

@dcaldastp
Copy link

Version

1.43.1

Steps to reproduce

  1. Configure a test id attribute
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    testIdAttribute: 'pw-test-id',
  },
});
  1. Create a test that uses page.getByTestId(...)
  2. Use page.getByTestId(...) in globalSetup function (probably the same happens for the teardown function)

Expected behavior

page.getByTestId(...) works seamlessly across setup/teardown functions and specs.

Actual behavior

I need to execute

import { selectors } from '@playwright/test'
selectors.setTestIdAttribute('pw-test-id')

In order for the selector to work as expected.

Additional context

No response

Environment

System:
    OS: macOS 14.4.1
    Memory: 185.98 MB / 16.00 GB
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
@dgozman
Copy link
Contributor

dgozman commented Apr 30, 2024

This is working as expected. If you would like your setup to be affected by the config, use project dependencies instead.

I'll try updating the docs to make this clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants