NodeJS Test Frameworks
JavaScript Frameworks
- CodeceptJS
- Cucumber
- Cucumber Java
- Cypress
- Detox
- Java Frameworks
- Jest
- JUnit
- Mocha
- Newman/Postman
- Playwright
- Protractor
- Selenide
- TestCafe
- Vitest
- WebdriverIO
Testomat.io reporter is NodeJS package that can be applied to all popular JavaScript test runners.
CodeceptJS
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Add plugin to codecept conf:
Run the following command from you project folder:
πΌ Screenshots of failed tests and videos (for Playwright helper) will be automatically uploaded as Artifacts
CodeceptJS Parallel Run
If tests run parallel, like workers in CodeceptJS use start-test-run
command to get proper reports:
Specify a command to run with
-c
option instart-test-run
Use --env-file <envfile>
option to load environment variables from .env file. Inside env file TESTOMATIO credentials like TESTOMATIO
api key or S3 config for artifacts.
Command start-test-run
is used to initiate a single run report before all workers are started. Each worker will report to the same Run, and after all workers and codeceptjs finishes, this will finish the run report.
π Example Project | π CodeceptJS API Example | π₯ CodeceptJS Cucumber Example
πΊ Video
Playwright
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Add a reporter to Playwright config:
Run the following command from you project folder:
πΌ Screenshots of failed tests and videos will be automatically uploaded as Artifacts
π Example Project | π₯ Playwright + Cucumber Example
Cypress
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
For Cypress < 10.0.0
(click to expand)
Register `cypress-plugin` in `cypress/plugins/index.js`:
For Cypress >= 10.0.0
use setupNodeEvents
in cypress.config.js(ts)
Run the following command from you project folder:
πΌ Screenshots of failed tests and videos will be automatically uploaded as Artifacts
π Example Project | π₯ Cypress + Cucumber Example
Mocha
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Run the following command from you project folder:
π Example Project
Jest
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Add the following line to jest.config.js:
Run tests:
Warning Do not use
bail
option in your jest config or testrun script. (It cause issues with updating testrun status).
π Example Project
πΊ Video
Vitest
When used with Testomat.io it is recommended to import automated tests first via check-tests. To create items on the fly set TESTOMATIO_CREATE=1
env variable.
- Install Testomatio reporter:
- Add Testomatio reporter to vitest.config.ts
You may also pass your API key
or pass it later via environment variable when running tests.
- Run tests:
π Example Project
Vitest reporter has some limitations:
- it does not support testomatio functions (but supports adding console.logs and vitest metadata to report)
- tests canβt be uploaded βon the flyβ, they sent to Testomat.io only after the run is finished (but vitest is supposed to be used as unit test framework, so your run should not take much time)
WebdriverIO
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Add the following lines to wdio.conf.js:
For making screenshots on failed tests add the following hook to wdio.conf.js
:
Run the following command from you project folder:
π Example Project
πΊ Video
Cucumber
π When used with Testomat.io Application it is recommended to import feature files via check-cucumber.
Run the following command from you project folder:
Note If you use Cucumber with Playwright, Cypress, CodeceptJS, please refer to corresponding framework. This reference is required only if you run tests via
cucumber-js
CLI.
π Example Project
πΊ Video
TestCafe
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Run the following command from you project folder:
Newman
To report Newman tests a separate package is required:
Note >
newman
andnewman-reporter-testomatio
should be installed in the same directory. If you run your tests using globally installed newman (newman run ...
), intallnewman-reporter-testomatio
globally too (npm i newman-reporter-testomatio -g
). If you use locally installed newman (within the project) (npx newman run ...
), installnewman-reporter-testomatio
locally (npm i newman-reporter-testomatio
). You can verify installed packages vianpm list
ornpm list -g
.
Run collection and specify testomatio
as reporter:
π Example Project
Detox
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Run detox tests sptcifying configuration name:
Warning Do not use
bail
option in your jest config or testrun script. (It cause issues with updating testrun status).
Protractor
π When used with Testomat.io Application it is recommended to import automated tests first via check-tests. To create items on the fly set
TESTOMATIO_CREATE=1
env variable.
Add the following lines to conf.js:
Run the following command from you project folder:
π Example Project
Java Frameworks
π This section describes reporting into Testomat.io Application
Reporting from Java Frameworks is done via JUnit XML report. Install @testomatio/reporter
NodeJS package to process reports:
JUnit XML report can be created by test framework you use:
JUnit
If you run JUnit tests via Maven you can use Surefire Report Plugin to generate JUnit XML report.
For example, with Surefire Report Plugin in Maven, you can add the following configuration to your projectβs pom.xml
:
In this case JUnit XML will be saved into target/surefire-reports/
So you can import reports to Testomat.io by running:
Note If your tests are located in a folder other other than
src/test/java
, specify a path to test files using--java-tests
option:--java-tests="path/to/tests"
This will import test reports into Testomat.io. If a reporter can access source code of Java tests, the source code will also be imported into Testomat.io
Test IDS
It is possible to attach reported tests to the current tests in Testomat.io by their IDs. Copy Test ID of a test you want to match, and put it as a comment into a Java test you want to import.
In this example, we added ID as a comment to negativeNumbersCanBeSubtracted
test:
To make this feature work, please ensure that source code of Java tests is accessible to npx report-xml
command, use --java-tests
option to specify the correct path. To check if source code of tests is available run reporter with DEBUG mode:
Is a source code is not available, test IDs can be set from output. To set Test ID to a test, copy test ID and print it from a test:
For example, if your test id is @T8acca9eb
you can print it:
Artifacts
Screenshots or videos from tests are uploaded if test contains output with a path to file of following format:
Use System.out.println
to print an absulute path to file that should be uploaded as a screenshot.
This will produce XML report which contains path to a file:
When XML report is uploaded, all files from file://
will be uploaded to corresponding tests.
πΌ Read more how Artifacts work
Selenide
Please refer to JUnit if you use JUnit as a test runner for Selenide tests.
However, it is important to note, that Selenide automatically adds artifacts into JUnit reports printing them as file://
into XML report. This means that no code changes should be made to publish artifacts to Testomat.io.
Cucumber Java
If you use Java version of Cucumber Java you should import your feature files first using check-cucumber.
Provide a path to directory containing feature files by using -d
option:
It is recommended to set Test IDs for Cucumber scenarios to make reports match imported tests.
We use --update-ids
option to write test IDs obtained from Testomat.io into source code
Also we use TESTOMATIO_TITLE_IDS=1
to write test IDs into scenario titles instead of scenario tags. This is important so JUnit report would contain test IDs.
To generate JUnit reports, you can use the built-in Cucumber JUnit plugin. When you run your Cucumber tests the JUnit reports will be generated in the default directory (build/reports/tests/test
) in XML format.
To submit report to Testomat.io use npx report-xml
command from @testomatio/reporter
NodeJS package:
If you want to have artifacts attached, use System.out.println
to print an absulute path to file that should be uploaded as a screenshot.