vitalets/playwright-bdd

Bug: When using allure report with cucumber, screenshot are not shown in the allure report.

Closed this issue · 6 comments

Given
Setup config :

export default defineConfig({
  testDir,
  snapshotPathTemplate: './fixtures/__screenshots__/{testFilePath}/{arg}{ext}',
  /* Run tests in files in parallel */
  fullyParallel: true,
  /* Fail the build on CI if you accidentally left test.only in the source code. */
  forbidOnly: !!process.env.CI,
  /* Retry on CI only */
  retries: process.env.CI ? 2 : 0,
  /* Opt out of parallel tests on CI. */
  workers: process.env.CI ? 2 : 5,
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
  reporter: [
    ['./node_modules/playwright-slack-report/dist/src/SlackReporter.js', { sendResults: 'off' }],
    ['blob'], ['list'], ['allure-playwright', { outputFolder: `allure-results` }]
  ],
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
  use: {
    baseURL: (process.env.BASE_URL || config.baseUrl),
    trace: 'off',
    navigationTimeout: 60000,
    actionTimeout: 42000,
    screenshot: 'only-on-failure'
  },
  expect: { timeout: 42000 },
  timeout: 480000,
  /* Configure projects for major browsers */
  projects: [
    {
      name: 'setup',
      testMatch: /^.+\.setup\.ts/,
      testDir: './setup'
    },
    {
      name: `chrome_${ environment }`,
      use: {
        ...devices['Desktop Chrome'],
        launchOptions: { args: ['--disable-gpu'] },
        contextOptions: { screen: { width: 1920, height: 1024 } },
        deviceScaleFactor: 1,
        viewport: { width: 1920, height: 1024 },
        storageState: '.auth/storageState.json'
      },
      dependencies: ['setup']
    }
  ]
});

When

"npx bddgen --tags 'not @teststeardown' && npx playwright test --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL",

Then

No error, just no screenshot appear when test are failing while I have screenshot: 'only-on-failure' option set.

But I expect

Screenshot appearing in my allure report.

Environment

Playwright-bdd environment info:

platform: darwin
node: v21.1.0
playwright-bdd: v7.5.0
@playwright/test: v1.49.0
@cucumber/cucumber: none
Playwright config file: playwright.config.ts

I've tried on playwright-bdd-example + allure. It shows screenshot and video inside After Hooks block, that is collapsed by default:
image

Could you check on your side?

I don't have it, that's weird then, I will take a look more deeply, I don't have the issue when I don't use the plugin

Could you also try to run without sharding

Okey, I will see that too

Hello, I will close this ticket, I've found the screenshot as you said in your first comment in the After Hooks, it seem that when I was merging shard, it was removing .png file, I fixed it (not sure why it happened like that by default on our old code)
Thanks for your answer !

Just an idea, shouldn't it be better to show the screenshot in the failing assertion/action ?

You are welcome!

shouldn't it be better to show the screenshot in the failing assertion/action ?

I agree. Will investigate in #249