github.com/jaylevin/jenkins-library@v1.230.4/resources/metadata/karmaExecuteTests.yaml (about)

     1  metadata:
     2    name: karmaExecuteTests
     3    description: Executes the Karma test runner
     4    longDescription: |
     5      In this step the ([Karma test runner](http://karma-runner.github.io)) is executed.
     6  
     7      The step is using the `seleniumExecuteTest` step to spin up two containers in a Docker network:
     8  
     9      * a Selenium/Chrome container (`selenium/standalone-chrome`)
    10      * a NodeJS container (`node:lts-stretch`)
    11  
    12      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](https://karma-runner.github.io/1.0/config/configuration-file.html) and [WebDriver](https://github.com/karma-runner/karma-webdriver-launcher#usage)).
    13  
    14      !!! note
    15          In a Kubernetes environment, the containers both need to be referenced with `localhost`.
    16  spec:
    17    inputs:
    18      secrets:
    19        - name: seleniumHubCredentialsId
    20          type: jenkins
    21          description: "Defines the id of the user/password credentials to be used to connect to a Selenium Hub. The credentials are provided in the environment variables `PIPER_SELENIUM_HUB_USER` and `PIPER_SELENIUM_HUB_PASSWORD`."
    22      resources:
    23        - name: buildDescriptor
    24          type: stash
    25        - name: tests
    26          type: stash
    27      params:
    28        - name: installCommand
    29          type: string
    30          description: The command that is executed to install the test tool.
    31          default: npm install --quiet
    32          scope:
    33            - GENERAL
    34            - PARAMETERS
    35            - STAGES
    36            - STEPS
    37          mandatory: true
    38        - name: modules
    39          type: "[]string"
    40          description: Define the paths of the modules to execute tests on.
    41          default: ["."]
    42          scope:
    43            - PARAMETERS
    44            - STAGES
    45            - STEPS
    46          mandatory: true
    47        - name: runCommand
    48          type: string
    49          description: The command that is executed to start the tests.
    50          default: npm run karma
    51          scope:
    52            - GENERAL
    53            - PARAMETERS
    54            - STAGES
    55            - STEPS
    56          mandatory: true
    57    outputs:
    58      resources:
    59        - name: reports
    60          type: reports
    61          params:
    62            - filePattern: "**/TEST-*.xml"
    63              type: karma
    64            - filePattern: "**/cobertura-coverage.xml"
    65              type: karma
    66            - filePattern: "**/TEST-*.xml"
    67              type: junit
    68            - filePattern: "**/jacoco.xml"
    69              type: jacoco-coverage
    70            - filePattern: "**/cobertura-coverage.xml"
    71              type: cobertura-coverage
    72            - filePattern: "**/xmake_stage.json"
    73              type: xmake
    74            - filePattern: "**/requirement.mapping"
    75              type: requirement-mapping
    76    containers:
    77      - name: karma
    78        image: node:lts-stretch
    79        env:
    80          - name: no_proxy
    81            value: localhost,selenium,$no_proxy
    82          - name: NO_PROXY
    83            value: localhost,selenium,$NO_PROXY
    84          - name: "PIPER_SELENIUM_HOSTNAME"
    85            value: "karma"
    86          - name: "PIPER_SELENIUM_WEBDRIVER_HOSTNAME"
    87            value: "selenium"
    88          - name: "PIPER_SELENIUM_WEBDRIVER_PORT"
    89            value: "4444"
    90        workingDir: /home/node
    91        volumeMounts:
    92          - mountPath: /dev/shm
    93            name: dev-shm
    94    sidecars:
    95      - image: selenium/standalone-chrome
    96        name: selenium
    97        securityContext:
    98          privileged: true
    99        volumeMounts:
   100          - mountPath: /dev/shm
   101            name: dev-shm
   102        env:
   103          - name: "NO_PROXY"
   104            value: "localhost,karma,$NO_PROXY"
   105          - name: "no_proxy"
   106            value: "localhost,selenium,$no_proxy"