Comparison with Cucumber
Leftest can be thought of as a lightweight TypeScript interpretation of Gherkin syntax and Cucumber. Instead of IDE plugins it relies on type checking to get a reasonable DX with autocompletion and type checking of parameterised steps.
Gherkin feature files can be translated directly to Leftest syntax.
- Gherkin
- Leftest
Feature: Guess the word
Scenario: Maker starts a game
When the Maker starts a game
Then the Maker waits for a Breaker to join
feature('Guess the word', () => {
scenario('Maker starts a game', () => {
when('the Maker starts a game')
then('the Maker waits for a Breaker to join')
})
})
Here's another example using scenario outline
- Gherkin
- Leftest
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
scenario('eating', () => {
given('there are <start> cucumbers')
when('I eat <eat> cucumbers')
then('I should have <left> cucumbers')
examples([
{ start: 12, eat: 5, left: 7 },
{ start: 20, eat: 5, left: 15 },
])
})
IntelliJ IDEA
For the best experience with IntelliJ IDEA:
Open settings Editor > Language Injections
Disable HTML in JS Strings
If you have it installed, also disable the Cucumber.js plugin. This plugin interferes with go-to definition for steps.