Naming Conventions

Naming conventions of Page Objects

When developing a testing framework, it is a good idea to have some naming convention standards for each type of files you create. In this particular case, Codecptjs-BDD automatically injects the Page Objects to your Step Definitions or Tests files by scanning through your test code - so,it is very important to follow the Page Objects Naming Conventions.

❓Why to follow the naming conventions for Page Objects?

Codeceptjs has created the Page Objects Dependency Injection, which requires developers to include all the page objects in the configuration file. Which is a manual and very tedious process to include Page Objects each time you create new.

πŸ’― The Codecpetjs-BDD framework automates the entire process of dependency injections and eliminates the need to define page objects manually in the configurations. Just follow the below conventions.

🌈 Two conventions of Page Objects

  1. All the Page Objects must be under pages directory
  2. Page Objects file name must have *.page.js extension
    pages/<page-name>.page.js

πŸ”Ž How Codecpejts-BDD injects the page objects into your tests?

Page Objects are mapped to camelCase attributes in the tests, while the file name can follow any patterns, e.g. kebab case or dots etc.

e.g. any of below Page Objects will be mapped to myAccount attribute in tests.

  1. my-account.page.js (recommended)
  2. my.account.page.js
  3. my_account.page.js
  4. myAccount.page.js

βœ…To inject in tests,

const { myAccount } = inject();


LocatorsDocker & Jenkins CI