-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added runner compatibility that does not globally expose the 'd…
…escribe' and 'test' methods
- Loading branch information
Showing
11 changed files
with
4,571 additions
and
2,238 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
examples/typescript/specs/step-definitions/auto-binding/auto-step-binding.steps.vitest.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 { expect } from 'vitest'; | ||
import { StepDefinitions, loadFeatures, autoBindSteps } from '../../../../../src'; | ||
import { VendingMachine } from '../../../src/vending-machine'; | ||
|
||
export const vendingMachineSteps: StepDefinitions = ({ given, and, when, then }) => { | ||
let vendingMachine: VendingMachine; | ||
|
||
given(/^the vending machine has "(.*)" in stock$/, (itemName: string) => { | ||
vendingMachine = new VendingMachine(); | ||
vendingMachine.stockItem(itemName, 1); | ||
}); | ||
|
||
and('I have inserted the correct amount of money', () => { | ||
vendingMachine.insertMoney(0.5); | ||
}); | ||
|
||
when(/^I purchase "(.*)"$/, (itemName: string) => { | ||
vendingMachine.dispenseItem(itemName); | ||
}); | ||
|
||
then(/^my "(.*)" should be dispensed$/, (itemName: string) => { | ||
const inventoryAmount = vendingMachine.items[itemName]; | ||
expect(inventoryAmount).toBe(0); | ||
}); | ||
}; | ||
|
||
const features = loadFeatures('./examples/typescript/specs/features/auto-binding/**/*.feature'); | ||
|
||
autoBindSteps(features, [vendingMachineSteps]); |
29 changes: 29 additions & 0 deletions
29
examples/typescript/specs/step-definitions/basic-scenarios.steps.vitest.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 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { expect, beforeEach } from 'vitest'; | ||
import { loadFeature, defineFeature } from '../../../../src'; | ||
import { PasswordValidator } from '../../src/password-validator'; | ||
|
||
const feature = loadFeature('./examples/typescript/specs/features/basic-scenarios.feature'); | ||
|
||
defineFeature(feature, test => { | ||
let passwordValidator = new PasswordValidator(); | ||
let accessGranted = false; | ||
|
||
beforeEach(() => { | ||
passwordValidator = new PasswordValidator(); | ||
}); | ||
|
||
test('Entering a correct password', ({ given, when, then }) => { | ||
given('I have previously created a password', () => { | ||
passwordValidator.setPassword('1234'); | ||
}); | ||
|
||
when('I enter my password correctly', () => { | ||
accessGranted = passwordValidator.validatePassword('1234'); | ||
}); | ||
|
||
then('I should be granted access', () => { | ||
expect(accessGranted).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.