-
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 configuration option to provide labels to all the tests (via #1217)
- Loading branch information
Showing
14 changed files
with
343 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect, it } from "vitest"; | ||
import { runCucumberInlineTest } from "../utils.js"; | ||
|
||
it("should handle global labels", async () => { | ||
const { tests } = await runCucumberInlineTest( | ||
["examples"], | ||
["examples"], | ||
undefined, | ||
(reporterFilePath) => ` | ||
module.exports = { | ||
default: { | ||
paths: ["./**/*.feature"], | ||
format: ["summary", "${reporterFilePath}"], | ||
formatOptions: { | ||
globalLabels: [ | ||
{ | ||
name: "foo", | ||
value: "bar" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
`, | ||
); | ||
|
||
expect(tests).toHaveLength(2); | ||
expect(tests[0].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
expect(tests[1].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
}); |
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,43 @@ | ||
import { expect, it } from "vitest"; | ||
import { runCypressInlineTest } from "../utils.js"; | ||
|
||
it("should handle global labels", async () => { | ||
const { tests } = await runCypressInlineTest({ | ||
"cypress/e2e/sample.cy.js": () => ` | ||
it("passed", () => { | ||
cy.wrap(1).should("eq", 1); | ||
}); | ||
`, | ||
"cypress.config.js": ({ allureCypressReporterModulePath, supportFilePath, specPattern, allureDirPath }) => ` | ||
const { allureCypress } = require("${allureCypressReporterModulePath}"); | ||
module.exports = { | ||
e2e: { | ||
baseUrl: "https://allurereport.org", | ||
supportFile: "${supportFilePath}", | ||
specPattern: "${specPattern}", | ||
viewportWidth: 1240, | ||
setupNodeEvents: (on, config) => { | ||
allureCypress(on, config, { | ||
resultsDir: "${allureDirPath}", | ||
globalLabels: [ | ||
{ | ||
name: "foo", | ||
value: "bar" | ||
} | ||
] | ||
}); | ||
return config; | ||
}, | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(tests).toHaveLength(1); | ||
expect(tests[0].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
}); |
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,33 @@ | ||
import { expect, it } from "vitest"; | ||
import { runJasmineInlineTest } from "../utils.js"; | ||
|
||
it("should handle global labels", async () => { | ||
const { tests } = await runJasmineInlineTest({ | ||
"spec/sample.spec.js": ` | ||
it("should pass 1", () => { | ||
expect(true).toBe(true); | ||
}); | ||
`, | ||
"spec/helpers/allure.js": ` | ||
const AllureJasmineReporter = require("allure-jasmine"); | ||
const reporter = new AllureJasmineReporter({ | ||
testMode: true, | ||
globalLabels: [ | ||
{ | ||
name: "foo", | ||
value: "bar" | ||
} | ||
] | ||
}); | ||
jasmine.getEnv().addReporter(reporter); | ||
`, | ||
}); | ||
|
||
expect(tests).toHaveLength(1); | ||
expect(tests[0].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
}); |
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,34 @@ | ||
import { expect, it } from "vitest"; | ||
import { runJestInlineTest } from "../utils.js"; | ||
|
||
it("should handle global labels", async () => { | ||
const { tests } = await runJestInlineTest({ | ||
"sample.spec.js": ` | ||
it("should pass", () => { | ||
expect(true).toBe(true); | ||
}); | ||
`, | ||
"jest.config.js": ({ allureJestNodePath }) => ` | ||
const config = { | ||
bail: false, | ||
testEnvironment: "${allureJestNodePath}", | ||
testEnvironmentOptions: { | ||
globalLabels: [ | ||
{ | ||
name: "foo", | ||
value: "bar" | ||
} | ||
] | ||
}, | ||
}; | ||
module.exports = config; | ||
`, | ||
}); | ||
|
||
expect(tests).toHaveLength(1); | ||
expect(tests[0].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
}); |
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
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
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
29 changes: 29 additions & 0 deletions
29
packages/allure-mocha/test/spec/framework/globalLabels.test.ts
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,29 @@ | ||
import { beforeAll, describe, expect, it } from "vitest"; | ||
import type { AllureResults } from "allure-js-commons/sdk"; | ||
import { runMochaInlineTest } from "../../utils.js"; | ||
|
||
describe("global labels", () => { | ||
let results: AllureResults; | ||
|
||
beforeAll(async () => { | ||
results = await runMochaInlineTest( | ||
{ | ||
globalLabels: [ | ||
{ | ||
name: "foo", | ||
value: "bar", | ||
}, | ||
], | ||
}, | ||
["plain-mocha", "testInSuite"], | ||
); | ||
}); | ||
|
||
it("should handle global labels", () => { | ||
expect(results.tests).toHaveLength(1); | ||
expect(results.tests[0].labels[0]).toEqual({ | ||
name: "foo", | ||
value: "bar", | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.