-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add categories and env info support for cypress
- Loading branch information
Showing
4 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { expect, it } from "vitest"; | ||
import { Status } from "allure-js-commons"; | ||
import { runCypressInlineTest } from "../utils.js"; | ||
|
||
it("has categories", async () => { | ||
const { categories } = await runCypressInlineTest({ | ||
"cypress/e2e/sample.cy.js": () => ` | ||
it('sample test', () => {}); | ||
`, | ||
"cypress.config.js": ({ allureCypressModuleBasePath }) => ` | ||
const { allureCypress } = require("${allureCypressModuleBasePath}/reporter.js"); | ||
module.exports = { | ||
e2e: { | ||
baseUrl: "https://allurereport.org", | ||
viewportWidth: 1240, | ||
setupNodeEvents: (on, config) => { | ||
allureCypress(on, { | ||
categories: [ | ||
{ | ||
name: "Sad tests", | ||
messageRegex: ".*Sad.*", | ||
matchedStatuses: ["${Status.FAILED}"], | ||
}, | ||
{ | ||
name: "Infrastructure problems", | ||
messageRegex: ".*RuntimeException.*", | ||
matchedStatuses: ["${Status.BROKEN}"], | ||
}, | ||
{ | ||
name: "Outdated tests", | ||
messageRegex: ".*FileNotFound.*", | ||
matchedStatuses: ["${Status.BROKEN}"], | ||
}, | ||
{ | ||
name: "Regression", | ||
messageRegex: "${String.raw`.*\\sException:.*`}", | ||
matchedStatuses: ["${Status.BROKEN}"], | ||
}, | ||
] | ||
}); | ||
return config; | ||
}, | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(categories).toEqual([ | ||
{ | ||
name: "Sad tests", | ||
messageRegex: ".*Sad.*", | ||
matchedStatuses: [Status.FAILED], | ||
}, | ||
{ | ||
name: "Infrastructure problems", | ||
messageRegex: ".*RuntimeException.*", | ||
matchedStatuses: [Status.BROKEN], | ||
}, | ||
{ | ||
name: "Outdated tests", | ||
messageRegex: ".*FileNotFound.*", | ||
matchedStatuses: [Status.BROKEN], | ||
}, | ||
{ | ||
name: "Regression", | ||
messageRegex: ".*\\sException:.*", | ||
matchedStatuses: [Status.BROKEN], | ||
}, | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect, it } from "vitest"; | ||
import { runCypressInlineTest } from "../utils.js"; | ||
|
||
it("has environment info", async () => { | ||
const { envInfo } = await runCypressInlineTest({ | ||
"cypress/e2e/sample.cy.js": () => ` | ||
it('sample test', () => {}); | ||
`, | ||
"cypress.config.js": ({ allureCypressModuleBasePath }) => ` | ||
const { allureCypress } = require("${allureCypressModuleBasePath}/reporter.js"); | ||
module.exports = { | ||
e2e: { | ||
baseUrl: "https://allurereport.org", | ||
viewportWidth: 1240, | ||
setupNodeEvents: (on, config) => { | ||
allureCypress(on, { | ||
environmentInfo: { | ||
envVar1: "envVar1Value", | ||
envVar2: "envVar2Value", | ||
}, | ||
}); | ||
return config; | ||
}, | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(envInfo).toEqual({ | ||
envVar1: "envVar1Value", | ||
envVar2: "envVar2Value", | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters