Giter Site home page Giter Site logo

playwright-test-only's Introduction

Playwright test.only

I ran into an issue with test.only in Playwright in a work project.

Error: focused item found in the --forbid-only mode:

In this repository I am trying to reproduce the issue.

I set up both the work repository and this one by following the Getting Started guide on https://playwright.dev with the exception that the work repository is a monorepo that uses PNPM and I do not yet know if that makes a difference.

https://playwright.dev/docs/intro

  1. npm init playwright@latest (I am using Node 20.2.0 and NPM 9.6.6)

    • TypeScript because that's what the work repository is using

      I don't know if the same issue reproduces in JavaScript.

    • tests as the directory for the tests

      In the work repository, I moved them straight to the directory root, but I do not think this matters. I will play around with this if I gain a suspicion it might play a role.

    • No to adding the GitHub Actions workflow

      I do make use of it in the work repository, but this problem happens in the IDE not in the workflow runtime so this should be unnecessary.

    • Install Playwright browsers automatically

      The workflow repository does it too and the workflow updates them there.

    At this point npx playwright test works successfully when I add test.todo to one of the generated sample tests.

  2. Remove the non-Chromium projects

    The reproduction should be unrelated to the browser at hand so let's simplify the setup.

  3. Change playwright.config.ts to look for tests in the repository directory root instead of in tests.

    • Change testDir from ./tests to ..

    Maybe this does play a role after all? Looks like that's not the case, npx playwright test still runs the sole test.

  4. Be confused. Next step: let's try to extract the reproduction out from the work repository instead.

    I will replace this repository with the result of that if I succeed.

    It is possible I just need to bump Playwright version in that repository?

The result

This message was printed because I had CI=1 set (as I was debugging a CI run issue) and did not realize that would set forbidOnly mode in the configuration file playwright.config.ts to be enabled (because I was using the initialized configuration file and did not take time to study all of the options) and as a result my use of test.only was explicitly forbidden.

I've opened a PR with a suggestion on how to improve this error message:

microsoft/playwright#23146

playwright-test-only's People

Contributors

tomashubelbauer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.