Skip to main content

CodeceptJS

Submit and collect your CodeceptJS tests in Testiny to track results over time, identify frequently failing tests, efficiently debug and fix CI failures or flaky tests.

Generate CodeceptJS Mochawesome JSON Reports

Install mocha and mochawesome packages if not installed yet and add the Mochawesome helper to your CodeceptJS config to capture screenshots:

codecept.conf.ts
// ...
export const config: CodeceptJS.MainConfig = {
// ...
helpers: {
// ...
Mochawesome: {}
},
// ...
}

Run your CodeceptJS tests with codeceptjs run --reporter mochawesome and the mochawesome reporter will create a report in the mochawesome-report folder. If you would like to store the report in another folder (e.g. the same folder as your screenshots), specify another output folder in your CodeCeptJS config:

codecept.conf.ts
// ...
export const config: CodeceptJS.MainConfig = {
// ...
mocha: {
"reporterOptions": {
"reportDir": "output",
},
},
// ...
}

Import Results to Testiny

Make sure you've generated an API key and use the Testiny CLI to import the results to Testiny:

export TESTINY_API_KEY=****
npx @testiny/cli automation --project ID_OR_KEY --source "e2e" --codeceptjs output/*.json e2e

In the above example, the environment variable TESTINY_API_KEY is set to authenticate the request. The --project flag specifies the target Testiny project using its ID or key and the --source flag categorizes the test results (e.g., frontend, backend, integration tests, ...). The --codeceptjs flag specifies the format of the specified test result file(s).

Once executed, the Testiny CLI will automatically create a new automated test run in Testiny and import all results from the specified report(s).

More resources

Here are some further resources to help you get started with integrating CodeceptJS with Testiny, including CI/CD integration examples, a full automation guide, and the Testiny CLI.