Where is a page object supposed to live? Mine is never picked up
Asked 9,640 views2 answers
26votes
I put my page object in projects/demo-shop/support/pages/LoginPage.ts because that is how our old framework was laid out. It compiles, the decorators are on the methods, and the class is exported. Every scenario that uses it still fails as an undefined step.
bash
sdods lint -p demo-shop
Is there a fixed folder for this, or a config key that tells the runner where to look?
The folder is fixed, and support/ is not one of them. Per project the runner globs exactly three things for step definitions: the core step library inside the package, steps/**/*.ts and pages/**/*.ts under the project root. A decorated class anywhere else is never loaded, so the steps it declares do not exist as far as generation is concerned.
text
projects/demo-shop/
sdods.project.yaml
envs/<env>.yaml
features/<module>/*.feature
pages/*.ts <- page objects, nested as deep as you like
steps/fixtures.ts <- the project test object
steps/auth.ts
Move LoginPage.ts to projects/demo-shop/pages/ and lint again. There is no key to add another directory, and that is on purpose — the generated specs have to import from one predictable place.
Adding to that: depth under pages/ is free, the glob is recursive, so pages/checkout/CartPage.ts is fine.
The second half people miss is registration. @Fixture<typeof test>('loginPage') names a fixture, and if steps/fixtures.ts does not declare one with that exact name there is nothing to bind the decorated methods to.