mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
3.8 KiB
3.8 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 | [ NO_PROXY: 'localhost,karma,$NO_PROXY', no_proxy: 'localhost,karma,$no_proxy'] |
|
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 | [ NO_PROXY: 'localhost,selenium,$NO_PROXY', no_proxy: 'localhost,selenium,$no_proxy'] |
|
sidecarImage | no | ||
sidecarName | no | ||
sidecarVolumeBind | no | ||
stashContent | no | ['buildDescriptor', 'tests'] |
script
- defines the global script environment of the Jenkinsfile run. Typicallythis
is passed to this parameter. This allows the function to access thecommonPipelineEnvironment
for storing the measured duration.containerPortMappings
- see step dockerExecutedockerEnvVars
- see step dockerExecutedockerImage
- see step dockerExecutedockerName
- see step dockerExecutedockerWorkspace
- see step dockerExecutefailOnError
- see step seleniumExecuteTestsinstallCommand
- the command that is executed to install dependenciesmodules
- define the paths of the modules to execute tests onrunCommand
- the command that is executed to start the testssidecarEnvVars
- see step dockerExecutesidecarImage
- see step dockerExecutesidecarName
- see step dockerExecutesidecarVolumeBind
- see step dockerExecutestashContent
- 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']