Skip to content

charlyautomatiza/starter-karate-dsl-npm

Repository files navigation

Twitch Discord

Karate DSL

API Test Automation - Karate DSL For Restful and GraphQL APIs

Starter project created live on Twitch.tv/CharlyAutomatiza based on Karate DSL for NodeJS/NPM Projects

Overview

Esta documentación está dispobible también en Castellano.

General requirements

Download and install

Installation of the testing framework

Clone the repository:

git clone https://github.com/charlyautomatiza/starter-karate-dsl-npm.git

Install dependencies.

npm install

To run the API Rest and GraphQL tests, go to the root of the project and run

npm run test ./src/features

WARNING: If you have errors please check Known Issues section and then re-try.

To run a specific API Rest test, for example the feature users.feature those cases with the @create_user tag.

npm run test -- ./src/features "--t @create_user"

To execute a specific test of the GraphQL API, for example in feature users-gql.feature those cases with the tag @graphql_examples.

npm run test -- ./src/features "-t @graphql_examples"

Another option:

npm run test:gql

To run all the API Rest and GraphQL tests, it can be run with the @run tag.

npm run test -- ./src/features "-t @run"

Another option:

npm run test:run

Running with N threads in parallel the cases that have the @run tag can be done with the -T N parameter. With the -C parameter the target folder is removed and created again with the new test results.

npm run test -- ./src/features "-t @run" "-T 5" "-C"
npm run test:parallel

The unified report of test results

After each execution, the reports in html format are generated in the target/karate-reports folder.

For more details you can consult the official documentation

Github Actions to run API tests

New folder .github/workflows with file karate-test-runner.yml to run our tests from a Github Actions pipeline.

JUnit Report retrieved from GitHub Marketplace

The workflow is configured to run on the following event:

  • push: when a repository is pushed.
  • Pull request: when a pull request is created.

Known Issues

Users on Windows have reported issues such as the npm install failing to complete and without any errors shown.

As a workaround, please install JBang manually and re-try the npm install step.