Gathering detailed insights and metrics for jest-circus-allure-playwright-environment
Gathering detailed insights and metrics for jest-circus-allure-playwright-environment
Gathering detailed insights and metrics for jest-circus-allure-playwright-environment
Gathering detailed insights and metrics for jest-circus-allure-playwright-environment
A Jest Circus environment for Allure reporting.
npm install jest-circus-allure-playwright-environment
Typescript
Module System
Min. Node Version
Node Version
NPM Version
39.8
Supply Chain
55.8
Quality
67.6
Maintenance
50
Vulnerability
94.3
License
TypeScript (90.64%)
JavaScript (9.36%)
Total Downloads
651
Last Day
1
Last Week
4
Last Month
10
Last Year
72
1 Stars
271 Commits
9 Branches
2 Contributors
Latest Version
1.0.2
Package Id
jest-circus-allure-playwright-environment@1.0.2
Unpacked Size
86.71 kB
Size
21.30 kB
File Count
22
NPM Version
6.14.9
Node Version
14.15.3
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
300%
4
Compared to previous week
Last month
400%
10
Compared to previous month
Last year
-36.8%
72
Compared to previous year
13
18
A Jest Circus Playwright environment for Allure reporting with Playwright .
Based on Jest Circus environment for Allure with build in features of Jest Playwright
Resource | Description |
---|---|
Jest | A delightful JavaScript testing framework. |
Allure 2 CLI | "A Java jar command line tool that turns Allure result files into beautiful Allure reports." |
1yarn add --dev jest-circus-allure-environment
jest.config.js
See the testEnvironment docs for configuration details.
1{ 2 "testEnvironment": "jest-circus-allure-environment", 3 "testRunner": "jest-circus/runner" 4}
1yarn test
1allure serve ./allure-results
To provide more information in your reports you can use Docblock pragmas within your tests. For types support you'll need some additional configuration.
1// simple.test.js 2 3test('2 + 3 is 5', () => { 4 /** My test description. 5 * @epic Implement addition functionality 6 * @tag Accounting 7 */ 8 9 expect(2 + 3).toBe(5) 10})
jest.setup.js
file1// jest.setup.js 2 3import 'jest-circus-allure-environment' // Typescript or ESM 4require('jest-circus-allure-environment') // CommonJS
jest.setup.js
file is properly configured.See the setupFilesAfterEnv docs for configuration details.
1// jest.config.js 2 3{ 4 "setupFilesAfterEnv": ["./jest.setup.js"] 5}
Options that can be passed into the environmentOptions
property of your jest.config.js
Parameter | Description | Default |
---|---|---|
resultsDir | Path where Allure result files will be written. | "allure-results" |
jiraUrl | URL to Jira instance. Any @issue docblock pragmas will link to this URL. | undefined |
tmsUrl | URL to TMS instance. Any @tms docblock pragmas will link to this URL. | undefined |
environmentInfo | Key value pairs that will appear under the environment section of the Allure report | {} |
categories | Array of custom categories you wish to see in the Allure report. See an example | [] |
testPath | Path to your test files. This path will be subtracted from the Allure report when organizing tests into suites. | Jest.config.rootDir |
You may set code comments inside your tests called DocBlocks, that can be parsed for specific allure report pragmas. These are the supported DocBlock pragmas you may add to a test.
Add descriptions that document the tested functionality.
1test('does something important, when triggered by user', () => { 2 /** This uses a 3rd party API that typically undergoes maintenance on Tuesdays. 3 */ 4 5 ... 6})
Tag a test with a custom label.
Set multiple tags using a ,
deliminator.
1test('does something important, when triggered by user', () => { 2 /** 3 * @tag beta 4 * @tag feature-flagged, api-v3 5 */ 6 7 ... 8})
Set an owner for a test.
1test('does something important, when triggered by user', () => { 2 /** 3 * @owner ios-team 4 */ 5 6 .. 7})
Mark tests with a severity rating to indicate the importance of the tested functionality in respect to the overall application.
Level | Description |
---|---|
blocker | Tests that if failing, will halt further development. |
critical | Tests that must pass; or risk disrupting crucial application logic. |
normal (default) | Tests that are of average importance to the overall application. |
minor | Tests that if failing, should only effect a small subset of the application. |
trivial | Tests that validate unreleased, disabled, or deprecated features. |
Example of setting a test as "critical" severity
1test('does something important, when triggered by user', () => { 2 /** 3 * @severity critical 4 */ 5 6 ... 7})
Mark tests with a behavior label to organize tests in a feature based hierarchy.
Level | Description |
---|---|
epic | Tests that if fail, will effect the expected functionality of an epic. |
feature | Tests that if fail, will effect the expected functionality of a feature. |
story | Tests that if fail, will effect the expected functionality of story. |
Example:
1test('validation message appears, when email field is skipped', () => { 2 /** 3 * @epic Automate user sign up 4 * @feature Registration page 5 * @story Validate required registration fields before creating new user 6 */ 7 8 ... 9})
Add Jira and TMS links to a test.
Level | Description |
---|---|
issue | Adds a link to the test report that will open an existing issue in Jira. |
tms | Adds a link to the test report that will open an existing test case in your test management system. |
Example:
1test('validation message appears, when email field is skipped', () => { 2 /** 3 * @issue DEBT-60 4 * @tms CORE-122 5 */ 6 7 ... 8})
An instance of the allure runtime will be available on the Node global variable. You can utilize it's APIs to provide custom reporting functionality.
1/** 2 * Returns the Allure test instance for the currently running test. 3 */ 4allure.currentTest(): AllureTest; 5 6/** 7 * Adds a description to the report of the current test. Supports markdown. 8 */ 9allure.description(markdown: string): void; 10 11/** 12 * Starts and returns a new step instance on the current executable. 13 */ 14allure.startStep(name: string): StepWrapper; 15 16/** 17 * Starts a new Allure step, sets the status, and adds any provided attachments (optional), then ends the step. 18 */ 19allure.logStep( 20 name: string, 21 status: Status, 22 attachments?: Array<{ name: string; content: string; type: ContentType }> 23): void; 24 25/** 26 * Add a parameter to the report of the current executable. 27 */ 28allure.parameter(name: string, value: string): void; 29 30/** 31 * Attach a file to the report of the current executable. 32 */ 33allure.attachment( 34 name: string, 35 content: Buffer | string, 36 type: ContentType 37); 38 39/** 40 * Add a issue link to the report of the current test. 41 */ 42allure.issue(id: string): void; 43 44/** 45 * Add a TMS link to the report of the current test. 46 */ 47allure.tms(id: string): void; 48 49/** 50 * Add a severity label to the report of the current test. 51 */ 52allure.severity(severity: Severity): void; 53 54/** 55 * Add a epic label to the report of the current test. 56 */ 57allure.epic(epic: string): void; 58 59/** 60 * Add a feature label to the report of the current test. 61 */ 62allure.feature(feature: string): void; 63 64/** 65 * Add a story label to the report of the current test. 66 */ 67allure.story(story: string): void; 68 69/** 70 * Add a tag label to the report of the current test. 71 */ 72allure.tag(name: string): void; 73 74/** 75 * Add a custom label to the report of the current test. 76 */ 77allure.label(name: string, value: string): void;
You can use jest-playwright with custom test environment for taking screenshots during test failures for example:
jest.config.json
1"testEnvironment": "./CustomEnvironment.js"
CustomEnvironment.js
1const AllurePlaywrightEnvironment = 2 require('jest-circus-allure-playwright-environment/dist/allure-playwright-environment').default 3class CustomEnvironment extends AllurePlaywrightEnvironment { 4 async setup() { 5 await super.setup() 6 // Your setup 7 } 8 async teardown() { 9 // Your teardown 10 await super.teardown() 11 } 12 async handleTestEvent(event) { 13 await super.handleTestEvent(event); 14 if (event.name === 'test_done' && event.test.errors.length > 0) { 15 const parentName = event.test.parent.name.replace(/\W/g, '-') 16 const specName = event.test.name.replace(/\W/g, '-') 17 await this.global.page.screenshot({ 18 path: `screenshots/${parentName}_${specName}.png`, 19 }) 20 } 21 } 22} 23module.exports = CustomEnvironment
No vulnerabilities found.
No security vulnerabilities found.