The driver on the World
Put the driver infeatures/support/todo-driver.ts, the code from the overview
with one change: the import names the .ts file ('../../src/backdoors.ts'; see
below).
Give the World a getter for it, and register that World instead of the default one:
registerQuiesco() replaces import '@quiesco/cucumber/register' in features/support/quiesco.ts; do
not keep both (registerQuiesco()).
Steps
Steps then read like the feature:this.platform is the same as this.app.platform (per-platform steps).
Step files are not compiled
cucumber-js loads step and support files with Node’s type stripping: Node removes the types and runs the rest as JavaScript, withouttsc. Two rules follow:
- Relative imports name the
.tsfile:import { UiTodoDriver } from './todo-driver.ts'.npx quiesco initadds"allowImportingTsExtensions": truetotsconfig.json, sotscaccepts them. - No TypeScript syntax that generates code: parameter properties
(
constructor(private app: Driver)),enumandnamespacefail withERR_UNSUPPORTED_TYPESCRIPT_SYNTAX. Declare the field and assign it in the constructor; use a union of string literals or an objectas constinstead of anenum.
npx cucumber-js --dry-run loads every step file without starting the app, so it finds both kinds of
mistakes in seconds.
The same features against the API
With anApiTodoDriver, the same
features run without the app. Select the driver with an environment variable or a cucumber profile. The
API run does not need Quiesco at all: give it its own World (a plain cucumber World with an
ApiTodoDriver) and leave out the Quiesco registration in that profile.
Generic steps
@quiesco/steps offers ready-made steps such as 点击 "add-todo" / "add-todo" をタップする /
I tap "add-todo". They are operation scripts — useful to explore an app or sketch a prototype, but they
tie features to the UI. Move to business-language steps as soon as the features describe real
requirements. See generic steps.
More on Cucumber in Cucumber.