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

feat(playwright): add support for attachments in steps #765

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

baev
Copy link
Member

@baev baev commented Aug 31, 2023

Context

Now, users may use allure.attachment API instead of test.info().attach to add attachments to the current step. Attachments created by the Playwright (screenshot diffs) are still added to the test instead of the current executed step. Related issue microsoft/playwright#14364

How to use

import test from '@playwright/test';
import { allure } from 'allure-playwright'
test('should add attachment to the step', async ({}, testInfo) => {
  await allure.step('outer step 1', async () => {
    await allure.step('inner step 1.1', async () => {
      await allure.attachment('some', 'some-data', 'text/plain');
    });
  });
});

Additional changes

All the Allure API methods (epic, feature etc) now need to be awaited. Playwright Core enforces this requirement since we communicate between workers to sync the metadata:

import test from '@playwright/test';
import { allure } from 'allure-playwright'
test('test with feature', async ({}, testInfo) => {
  await allure.feature("some feature")
});

fixes #436

Checklist

@baev baev added the type:new feature New feature or request label Aug 31, 2023
@baev baev requested review from vovsemenv and epszaw August 31, 2023 12:05
@baev baev merged commit caa8333 into master Aug 31, 2023
5 checks passed
@baev baev deleted the pw-attachments-in-steps branch August 31, 2023 15:05
@EgorBodnar
Copy link

@baev great work! Thanks, we've been waiting for it a lot

Will the feature be available in version 2.7 of allure-playwright?
Is it known when the new release with this feature is planned?

@paresh-celigo
Copy link

@baev I am facing this error for same use
image

@preethinaren
Copy link

How I can implement the allure.logStep in playwright cucumber JS framework
Error: Allure.logStep is not a function

code:
const { Allure, ContentType, AllureRuntime } = require("allure-js-commons");
const { CucumberAllureWorld } = require('allure-cucumberjs');
const allure = new Allure();

const modifiedFirstName = FirstName + randomString;
const modifiedLastName = LastName + randomString;

allure.logStep(`Modified First Name: ${modifiedFirstName}`); 
allure.logStep (`Modified Last Name: ${modifiedLastName}`);

package.json:
=======
"scripts": {
"test": "npx cross-env NODE_ENV=TEST cucumber-js --tags @test --require cucumber.js --require src/tests/step-definitions/**/*.js --format ./src/helper/report/allure-config.js",
"allure:generate": "npx allure generate ./allure-results --clean",
"allure:open": "allure open allure-report"

},

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

Successfully merging this pull request may close these issues.

[allure-playwright]: Need a new feature to add an attachment to a step.
5 participants