1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/karmaExecuteTests.md
Marcus Holl 7446b1e93d Remove return value from step documentation
In the meantime the steps do not have a return value anymore.
2018-11-09 16:09:29 +01:00

3.6 KiB

karmaExecuteTests

Description

In this step the (Karma test runner) is executed.

The step is using the seleniumExecuteTest step to spins up two containers in a Docker network:

  • a Selenium/Chrome container (selenium/standalone-chrome)
  • a NodeJS container (node:8-stretch)

In the Docker network, the containers can be referenced by the values provided in dockerName and sidecarName, the default values are karma and selenium. These values must be used in the hostname properties of the test configuration (Karma and WebDriver).

!!! note In a Kubernetes environment, the containers both need to be referenced with localhost.

Prerequisites

  • running Karma tests - have a NPM module with running tests executed with Karma
  • configured WebDriver - have the karma-webdriver-launcher package installed and a custom, WebDriver-based browser configured in Karma

Parameters

parameter mandatory default possible values
script yes
containerPortMappings no [node:8-stretch: [[containerPort: 9876, hostPort: 9876]]]
dockerEnvVars no
dockerImage no node:8-stretch
dockerName no karma
dockerWorkspace no /home/node
failOnError no
installCommand no npm install --quiet
modules no ['.']
runCommand no npm run karma
sidecarEnvVars no
sidecarImage no
sidecarName no
sidecarVolumeBind no
stashContent no
  • script - defines the global script environment of the Jenkinsfile run. Typically this is passed to this parameter. This allows the function to access the commonPipelineEnvironment for storing the measured duration.
  • containerPortMappings - see step dockerExecute
  • dockerEnvVars - see step dockerExecute
  • dockerImage - see step dockerExecute
  • dockerName - see step dockerExecute
  • dockerWorkspace - see step dockerExecute
  • failOnError - see step seleniumExecuteTests
  • installCommand - the command that is executed to install dependencies
  • modules - define the paths of the modules to execute tests on
  • runCommand - the command that is executed to start the tests
  • sidecarEnvVars - see step dockerExecute
  • sidecarImage - see step dockerExecute
  • sidecarName - see step dockerExecute
  • sidecarVolumeBind - see step dockerExecute
  • stashContent - pass specific stashed that should be considered for the tests

Step configuration

We recommend to define values of step parameters via config.yml file.

In following sections the configuration is possible:

parameter general step stage
script
containerPortMappings X X X
dockerEnvVars X X X
dockerImage X X X
dockerName X X X
dockerWorkspace X X X
failOnError X X X
installCommand X X X
modules X X X
runCommand X X X
sidecarEnvVars X X X
sidecarImage X X X
sidecarName X X X
sidecarVolumeBind X X X
stashContent X X X

Side effects

Step uses seleniumExecuteTest & dockerExecute inside.

Exceptions

none

Example

karmaExecuteTests script: this, modules: ['./shoppinglist', './catalog']