-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement basic assert in cucumber world
- Loading branch information
1 parent
bac858c
commit e259c2b
Showing
3 changed files
with
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ Feature: | |
|
||
Scenario: | ||
Given I start playing | ||
Then I will have fun | ||
Then the current turn is 1 |
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,10 +1,10 @@ | ||
import {Given, When} from '@cucumber/cucumber'; | ||
import {Given, Then} from '@cucumber/cucumber'; | ||
|
||
Given('I start playing', function () { | ||
|
||
this.start(); | ||
}); | ||
|
||
When('I will have fun', function () { | ||
|
||
Then('the current turn is {int}', async function (expected_turn) { | ||
await this.assert(({turn}) => turn === expected_turn); | ||
}); | ||
|
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,10 +1,20 @@ | ||
import {World, setWorldConstructor} from '@cucumber/cucumber'; | ||
import {waitFor} from 'xstate'; | ||
import game from '../src/game.js'; | ||
|
||
setWorldConstructor(class extends World { | ||
|
||
constructor(options) { | ||
super(options); | ||
} | ||
|
||
start() { | ||
this.game = game(); | ||
this.game.start(); | ||
} | ||
|
||
async assert(predicate) { | ||
await waitFor(this.game, ({context}) => predicate(context), {timeout: 2000}); | ||
} | ||
}); | ||
|