-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Can I use the default empty world when calling steps from steps? #255
Comments
This way: When("c", async function ({}) {
await a.call(this);
await b.call(this);
}); Will add it to docs. |
Thanks @vitalets, but it seems this doesn't work in my playwright-style example. I guess this will only work with cucumber-style steps. |
Confirm the bug, releasing as 8.0.1 |
Released in 8.0.1. const a = When("a", async function () {
this.a = 1;
});
const b = Then("b", async function () {
expect(this.a).toBe(1);
});
When("c", async function () {
await a.call(this);
await b.call(this);
}); |
Excellent, thank you @vitalets ! I managed to use it in the After block too: After.call(this, async function () {
// this.a
}); I think I can also define the default world type like this (I'm not sure if there's an easier way): interface MyWorldType extends Record<string, any> {
a: number;
}
const a = When("a", async function (this: MyWorldType) {
this.a = 1;
}); |
If it contains only interface MyWorldType {
a: number;
} |
Hi @vitalets, thanks for this project, it's working really well.
I noticed a default empty world was implemented for pw-style steps: #208 (comment)
How can I make use of this default empty world when calling steps from steps?
(using very latest
"playwright-bdd": "^8.0.0"
.)In this example, Test1 passes, but Test2 fails.
test.feature:
test.ts:
The text was updated successfully, but these errors were encountered: