-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
284 additions
and
28 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
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 |
---|---|---|
@@ -1,37 +1,220 @@ | ||
import { expect, it } from "vitest"; | ||
import { LabelName } from "allure-js-commons"; | ||
import { Status } from "allure-js-commons"; | ||
import { runCodeceptJsInlineTest } from "../utils.js"; | ||
|
||
it("should add correct bdd labels", async () => { | ||
it("should add bdd steps", async () => { | ||
const { tests } = await runCodeceptJsInlineTest({ | ||
"login.test.js": ` | ||
Feature("bdd") | ||
Scenario('bdd', () => { | ||
}).tag('@allure.label.epic:WebInterface') | ||
.tag('@allure.label.feature:EssentialFeatures') | ||
.tag('@allure.label.story:Authentication'); | ||
"features/basic.feature": `Feature: simple | ||
Scenario: passed | ||
Given a passed step`, | ||
"step_definitions/steps.js": ` Given("a passed step", () => { });`, | ||
"codecept.conf.js": ` | ||
const path = require("node:path"); | ||
const { setCommonPlugins } = require("@codeceptjs/configure"); | ||
setCommonPlugins(); | ||
exports.config = { | ||
output: path.resolve(__dirname, "./output"), | ||
plugins: { | ||
allure: { | ||
require: require.resolve("allure-codeceptjs"), | ||
enabled: true, | ||
}, | ||
}, | ||
gherkin: { | ||
features: "./features/*.feature", | ||
steps: ["./step_definitions/steps.js"], | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(tests).toHaveLength(1); | ||
expect(tests[0].labels).toEqual( | ||
expect.arrayContaining([ | ||
{ | ||
name: LabelName.EPIC, | ||
value: "WebInterface", | ||
}, | ||
{ | ||
name: LabelName.FEATURE, | ||
value: "EssentialFeatures", | ||
}, | ||
{ | ||
name: LabelName.STORY, | ||
value: "Authentication", | ||
}, | ||
]), | ||
); | ||
const [tr] = tests; | ||
expect(tr.steps).toMatchObject([ | ||
{ | ||
name: "Given a passed step", | ||
status: Status.PASSED, | ||
}, | ||
]); | ||
}); | ||
|
||
it("should support helper steps in bdd steps", async () => { | ||
const { tests } = await runCodeceptJsInlineTest({ | ||
"features/basic.feature": `Feature: simple | ||
Scenario: passed | ||
Given a world | ||
When we smile | ||
Then all good`, | ||
"step_definitions/steps.js": `const I = actor(); | ||
Given("a world", async () => { await I.pass(); }); | ||
When("we smile", async () => { await I.pass(); await I.next(); }); | ||
Then("all good", async () => { await I.next(); await I.pass(); await I.next(); await I.pass(); });`, | ||
"codecept.conf.js": ` | ||
const path = require("node:path"); | ||
const { setCommonPlugins } = require("@codeceptjs/configure"); | ||
setCommonPlugins(); | ||
exports.config = { | ||
output: path.resolve(__dirname, "./output"), | ||
plugins: { | ||
allure: { | ||
require: require.resolve("allure-codeceptjs"), | ||
enabled: true, | ||
}, | ||
}, | ||
gherkin: { | ||
features: "./features/*.feature", | ||
steps: ["./step_definitions/steps.js"], | ||
}, | ||
helpers: { | ||
CustomHelper: { | ||
require: "./helper.js", | ||
}, | ||
ExpectHelper: {}, | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(tests[0].labels.filter((l) => l.name === LabelName.EPIC)).toHaveLength(1); | ||
expect(tests[0].labels.filter((l) => l.name === LabelName.FEATURE)).toHaveLength(1); | ||
expect(tests[0].labels.filter((l) => l.name === LabelName.STORY)).toHaveLength(1); | ||
expect(tests).toHaveLength(1); | ||
const [tr] = tests; | ||
expect(tr.steps).toMatchObject([ | ||
{ | ||
name: "Given a world", | ||
steps: [ | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "When we smile", | ||
steps: [ | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I next", | ||
status: Status.PASSED, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Then all good", | ||
steps: [ | ||
{ | ||
name: "I next", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I next", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
|
||
it("should support failed bdd steps", async () => { | ||
const { tests } = await runCodeceptJsInlineTest({ | ||
"features/basic.feature": `Feature: simple | ||
Scenario: passed | ||
Given a world | ||
When we smile | ||
Then all good | ||
Then this one is ignored`, | ||
"step_definitions/steps.js": `const I = actor(); | ||
Given("a world", async () => { await I.pass(); }); | ||
When("we smile", async () => { await I.pass(); await I.next(); }); | ||
Then("all good", async () => { await I.next(); await I.fail(); }); | ||
Then(" this one is ignored", async () => { });`, | ||
"codecept.conf.js": ` | ||
const path = require("node:path"); | ||
const { setCommonPlugins } = require("@codeceptjs/configure"); | ||
setCommonPlugins(); | ||
exports.config = { | ||
output: path.resolve(__dirname, "./output"), | ||
plugins: { | ||
allure: { | ||
require: require.resolve("allure-codeceptjs"), | ||
enabled: true, | ||
}, | ||
}, | ||
gherkin: { | ||
features: "./features/*.feature", | ||
steps: ["./step_definitions/steps.js"], | ||
}, | ||
helpers: { | ||
CustomHelper: { | ||
require: "./helper.js", | ||
}, | ||
ExpectHelper: {}, | ||
}, | ||
}; | ||
`, | ||
}); | ||
|
||
expect(tests).toHaveLength(1); | ||
const [tr] = tests; | ||
expect(tr.steps).toMatchObject([ | ||
{ | ||
name: "Given a world", | ||
status: Status.PASSED, | ||
steps: [ | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "When we smile", | ||
status: Status.PASSED, | ||
steps: [ | ||
{ | ||
name: "I pass", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I next", | ||
status: Status.PASSED, | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Then all good", | ||
status: Status.BROKEN, | ||
statusDetails: { | ||
message: expect.stringContaining("an error"), | ||
}, | ||
steps: [ | ||
{ | ||
name: "I next", | ||
status: Status.PASSED, | ||
}, | ||
{ | ||
name: "I fail", | ||
status: Status.BROKEN, | ||
statusDetails: { | ||
message: expect.stringContaining("an error"), | ||
}, | ||
}, | ||
], | ||
}, | ||
]); | ||
}); |
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