Here’s a brief look at CodeceptJS and how it works?
What is CodeceptJS?
It is a modern end to end testing framework with a special BDD-style syntax. The test is written as a linear scenario of a user’s action on a site. Each test is described inside a Scenario function object passed into it. The object is an actor, an abstraction for a testing user. It supports multiple additional helpers to run code in Parallel, Multiple Browsers, etc.
A problem which we were facing in general skeleton:
- We were not able to handle different environments and unable to handle different URLs.
Solution: Now this can be handled in env.js
- There was no possible way to apply conditions on I.see and I.wait methods.
Solution: We have created custom helpers for that by using generic functions like I.isVisible(), isEnable() etc.
- Earlier we were unable to set environment through Command Line. Solution: Now we can pass different env through Command Line: For Windows: (SET e2e_env=dev) && codeceptjs run — steps For Linux: (e2e_env=dev) && codeceptjs run steps.
- Previously there were many Lines of Code in codecept.cofig.js. Solution: Now this has been made easy to understand and manageable by splitting the config file into multiple js files and grouping them into the config folder.
- Previously we were not able to handle static strings in a different language
Solution: Now this can be handled by using string.js and static string folder
New Features Added:
- Now we also added some preferences in WebDriver to download files in the project directory under the output folder.
- Created some generic methods which use all over the project.
- Also created some handlers to handle (CSV, Excel) and helpers (mongooseHelper and date picker)
- Now also use the autoLogin plugin.
Codeceptjs-Skeleton Structure:
Codecept Structure contains the following folders at the base level:
- Config
- Factories
- Features
- Model
- Output
- Pages
- Step_definition
config folder contains all the config files (helpers, custom helper, plugin, cucumber, include files ) which are used in codecept.config.js.
envConifg.js file is used to manage all the URLs of the app you can use those URLs like this:
envURL[envURL.env].web.HOST_URL at where you want to use URLs
And define your envConfig.js like this:
factories folder contains all the folders, files or function which can be used in all over the framework like.

- staticStrings — This folder contains js file which includes static messages of the application and is exported to string.js file and can be used as below: strings.SuccessMessage.publishMessage[“eng”]x
eng — the type of language.
- autoLogin.js — This codeceptjs plugin is used to login to the app and store token and session-id for the next login or scenario.
- datePicker.js — This contains generic date picker function which picks the date for components which use in the component library
- fileHandeler.js — This contains a function which is used to handle excel and CSV file.
genericFuctions.js -
- mongooHelper.js -
- MyHelper.js — contains a function in which the return status of the locator that is locator visible, is locator enable. The return type is Boolean
retryStatments.js -
- strings.js — This file contains all the required String objects which are exported from
staticString folder.
- ApiHelper.js — Contains different function which returns different base URLs.
Features — folder contains folder feature vise which contains all cucumber files having. feature extension.

Model — contains all the models which can be used in API as a request model or in web automation to store dynamic data if needed.
Output — contains all the output like screenshots and XML files and contains all downloaded files which are downloaded in between the scenarios.
Pages — contain all the page object(locators) and their relative functions.
step_definitions — contains all the definition of the steps which are specified in the feature file for both web and API.
How to run?
We can directly run scripts without changing the env by executing below command: npm run test:e2e This will execute on test env by default.
In order to execute script on different environment (SET AppEnv=dev) && npm run test:e2e
This will execute on dev environment.
Alternatively, user can execute scripts directly from codecept by below command codeceptjs run
— plugin allure — steps — For more details click on https://codecept.io/commands#run