json-to-cucumber

1.0.6 • Public • Published

Json-to-Cucumber

Description

Json-to-Cucumber is a utility package that transforms standard JSON reports generated from Playwright test runner, into Cucumber JSON reports that can be easily imported to test management platforms like Xray. It's designed in cases you dont want to implement full layer of Cucumber framework in your test automation, but you still want to have the scenarios documented in Gherkin syntax.

Installation

To install json-to-cucumber, run the following command in your project directory:

npm install json-to-cucumber

This command will look for a report.json file in the src/ directory of your project, transform it into a Cucumber JSON report, and output the result.

Usage

The tests should be organized using Playwright built-in steps, something like this:

test('Should do something'), async () => {
	test.info().annotations.push({
		type: 'Jira',
		description: 'PROJECT-8134',
	});

	await test.step(`GIVEN a contact is created`, async () => {
		//your GIVEN code here
	});

	await test.step(`WHEN a product is purchased`, async () => {
		//your WHEN code here
	});

	await test.step(`THEN policy is created`, async () => {
		//your THEN code here
	});
});

Each test should have annotation as well, that will be used later to map the test to the existing Xray feature file.

Playwright should be configured to generate Json report

//playwright.config.ts
reporter: [['json', { outputFile: 'report.json' }]],

assuming the src directory under the project root (meaning report would have the path src/report.json).

Then you create a npm script in your project:

//package.json
...
"scripts": {
		"cucumberize": "cucumberizeJson"
	},
...

Once Playwright report generated, you can run npm run cucumberize and it will transform the original json report to Cucumber json report (in the src/output directory) including all the steps and annotations.

You can easily integrate this results in Xray now 😀

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i json-to-cucumber

    Weekly Downloads

    2

    Version

    1.0.6

    License

    ISC

    Unpacked Size

    7.03 kB

    Total Files

    3

    Last publish

    Collaborators

    • kantaronpm