microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.43k stars 3.63k forks source link

[Bug]: Playwright Extension Test Explorer cannot find setup.ts files #30838

Closed Alice3105 closed 5 months ago

Alice3105 commented 5 months ago

Version

@playwright/test": "^1.45.0-alpha-2024-05-15 Playwright Test for VSCode v1.1.1 by Microsoft

Steps to reproduce

Previously, on Playwright version 1.36.1 I was able to see the projects I set up via setup.ts files on Test Explorer. However, after updating to 1.44.0 I cannot see that anymore.

I created 3 setup.ts files as projects that are located at the same directory as the playwright-settings.env and playwright.config.ts.

The folder structure of e2e: image

Projects are setup as below in the playwright.onfig.ts

export default defineConfig({
  testDir: '.',
  testIgnore: [''],

  timeout: 10 * 60 * 1000, // Global timeout test cases = 10 mins

  forbidOnly: !!process.env.CI,
  retries: 2,
  workers: process.env.CI ? 5 : 3,
  fullyParallel: false, // One worker runs on each .spec.ts file

  reporter: [
    ['junit', { outputFile: 'test-results/results.xml' }],
    ['html', { outputFolder: 'playwright-test-results' }]
  ],

  use: {
    // Using `await page.goto('/')` in code will go to the baseURL stated below
    baseURL: `${process.env.TARGET}${process.env.LANGUAGE}`,

    // Collect tracing (images) after failing the first time
    trace: 'on-first-retry'
  },

  projects: [
    {
      name: 'setup-authentication',
      testMatch: /.*\authentication.setup\.ts/
    },
    {
      name: 'teardown',
      testMatch: /.*\global.teardown.setup\.ts/,
      use: { storageState: './user.json' }
    },
    {
      name: 'setup-estimate',
      testMatch: /.*\estimate.setup\.ts/,
      dependencies: ['setup-authentication'],
      use: { storageState: './user.json' }
    },
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
        storageState: './user.json',
        launchOptions: {
          args: ['--auth-server-allowlist=""']
        },
        viewport: { width: 1920, height: 1080 }
      },
      dependencies: ['setup-estimate'],
      teardown: 'teardown'
    }
  ]
});

Now click on Testing -> Test Explorer

Expected behavior

I expect to see all the project names of setup.ts files (in the test-suites folder) appear here.

Actual behavior

Only the testes of the spec.ts appear.

Additional context

I used this playwright extension on vscode Playwright Test for VSCode v1.1.1 image

Everything run smoothly with CLI though.

When Test Explorer recognize the setup, I can run the test with the green triangle. However, that option is no longer available after updating the playwright library to 1.44.0

image

Environment

System:
    OS: Windows 11 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
    Memory: 7.25 GB / 31.68 GB
  Binaries:
    Node: 20.13.1 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    VSCode: 1.89.1
gvaatstra commented 5 months ago

Please see this response on disappeared projects: https://github.com/microsoft/playwright/issues/30843#issuecomment-2114861552

yury-s commented 5 months ago

Folding into https://github.com/microsoft/playwright/issues/30803

pavelfeldman commented 5 months ago

I believe all the associated issue have been fixed, please refer to https://github.com/microsoft/playwright/issues/30882 for details.