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.39k stars 3.63k forks source link

[QUESTION] some actions are behind 'After Hooks' and are not recorded #28424

Closed HilalPosluoglu closed 10 months ago

HilalPosluoglu commented 10 months ago

System info

Source code

Config file

// playwright.config.js
const { defineConfig, devices } = require('@playwright/test');
require('dotenv').config();
module.exports = defineConfig({
  testDir: './tests',
    timeout: 240 * 1000,
    expect: {
    timeout: 60* 1000,
  },
  fullyParallel: true,

  forbidOnly: !!process.env.CI,

  retries: process.env.CI ? 1 : 0,

  workers: process.env.CI ? 1 : undefined, /* 1 worker is recommended by playwright for CI environments

  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  reporter: 'html',
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    userAgent: 'testing_agent',
    httpCredentials: {
      username: 'xxx',
      password: 'xxx_pwd'
    },
    baseURL: process.env.BASE_URL,
    trace: "on", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
    video: "on",
    screenshot: "on"
  },

  /* Configure projects for major browsers */
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],

  /* Run your local dev server before starting the tests */
  // webServer: {
  //   command: 'npm run start',
  //   url: 'http://127.0.0.1:3000',
  //   reuseExistingServer: !process.env.CI,
  // },
});

image

[Describe expected behavior]

Actions should run before After Hooks

[Describe actual behavior]

Some of the actions (red marked on screenshot) run after the 'After Hooks' Hello all, What am I doing wrong here? This my second project in playwright. In the first project I didn't face an issue like this and evreything went well. Why are here some actions taking place after 'After Hooks' ?

jstbing commented 10 months ago

I think I'm having roughly the same problem. Some test failures are completed in the wrong order. Closing of fixtures (After Hooks) occurs ahead of time. The problem will not always be reproduced

Screenshot from the report:

image

I used several debug events (pw:api pw:test) Here I also see that in the process of closing the fixtures, logs are generated from the test step

image image

Tried it on versions 1.38.1 and 1.40.1.

pavelfeldman commented 10 months ago

If this is a bug report, please follow the [BUG] report template to file something we can reproduce.

HilalPosluoglu commented 10 months ago

SOLVED: it was just a simple missing 'await' in front of some function calls which caused the mentioned error !!!