playwright metadata for a test suite

Viewed 255

I am trying to add some custom metadata information in my tests like below

test.describe('my test suite',()=>{
    test('my first p0 test',()=>{}).meta({
      priority:0,
      
    });
    test('my first p0 test',() = {}).meta({ priority:1});
}).meta({
  owningTeam: 'business-ux'
});

and use the metadata to target set of test to run. Can you please help me with what support we have for such requirements in playwright?

2 Answers

You can combine playwright with allure.

installing it with

npm i -D @playwright/test allure-playwright

or you can add it into playwright.config.ts:

{
  reporter: "allure-playwright";
}

see more on https://www.npmjs.com/package/allure-playwright

And also you can add test.steps and priority and test name and description and lot more meta data that it supported by allure.

I ended up following this pattern to capture additional metadata.

interface ITestMetadata {
  priority: number;
  owner: string;
}

const testWrapper = (metadata: ITestMetadata) => {
  console.log(
    `Test owner ${metadata.owner}, test Priority ${metadata.priority}`
  );
  return base.extend({});
};
// ----- and in test file --- 
const test = testWrapper({
  owner: "playwright",
  priority: 0,
});

test.describe("Capture additional metadata", () => {
  test("metadata being captured", () => {
    expect(1).toBe(1);
  });
}); 
Related