allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

[allure-js] Is it possible to add actual request and response in the steps?

Open gg-jaycee-suarez opened this issue 2 years ago • 4 comments

Is it possible to attach actual request and response in the test steps?

`e.g in Python

allure.attach() ?`

gg-jaycee-suarez avatar Jul 25 '22 10:07 gg-jaycee-suarez

I want to add in the report that each time I send request from a test endpoint I can add it in the report both request and response.

gg-jaycee-suarez avatar Jul 25 '22 10:07 gg-jaycee-suarez

you can use playwright attachments and is will aper in you allure report

import { test } from "@playwright/test";
import { allure } from "allure-playwright";
test("simpleTest", async ({ page }, testInfo) => {
  allure.epic("this test is epic");
  testInfo.attach("filename.txt"); // attach any files like this

  await page.goto("https://web.telegram.org/k/");
  test.expect(true).toBe(false);
});

vovsemenv avatar Jul 29 '22 10:07 vovsemenv

@vovsemenv thank you, I am able to attach the payload request and response of the API. However it should be inside the Given, When and Then test steps only. The 'this.attach()' is available only inside the Given..

And also the attachments are added after the last step of the feature.

image

gg-jaycee-suarez avatar Jul 30 '22 01:07 gg-jaycee-suarez

For now you can't see step attachments due to https://github.com/microsoft/playwright/issues/14364 . also added more detailed info of steps and attachments usage in README

vovsemenv avatar Aug 10 '22 05:08 vovsemenv

@gg-jaycee-suarez with the new version on cucumber-integration this.attach will be available inside Given, When and Then

vovsemenv avatar Nov 25 '22 15:11 vovsemenv

Now you can use this.atach() in cucumber integration. update and read more https://github.com/allure-framework/allure-js/tree/master/packages/allure-cucumberjs#using-allure-api

vovsemenv avatar Feb 09 '23 08:02 vovsemenv