import { Before, Given, When, Then, defineParameterType } from '@cucumber/cucumber' import assert from 'node:assert/strict' defineParameterType({ name: 'tobe', regexp: [ /is/, /is not/ ], transformer: x => x === 'is' }) When('I interpret "to be" as a type', function () { }) Then('true {tobe} true', function (predicate) { assert(predicate) }) Then('false {tobe} true', function (predicate) { assert(!predicate) }) defineParameterType({ name: 'date', regexp: /\d{2}\.\d{2}\.\d{4}/ }) When('a date {date} is given', function (dateString) { const parts = dateString.split('.').reverse() this.date = new Date(...parts) }) Then('it gets converted to a Date object', function () { assert(this.date instanceof Date) }) Before(function () { this.count = 0 }) Given(/(a regular expression|it) matches (this|that) pattern/, function (_x, _y) { ++this.count }) Then('the step definition should be called twice', function () { assert.equal(this.count, 2) })