# Copyright (c) Microsoft Corporation and contributors. All rights reserved. # Licensed under the MIT License. # include-task-test template to run a single task test with/without coverage parameters: - name: taskTestStep type: string - name: buildDirectory type: string - name: testCoverage type: boolean default: false steps: # Test - With coverage - ${{ if and(parameters.testCoverage, startsWith(parameters.taskTestStep, 'ci:test')) }}: - task: Bash@3 displayName: npm run ${{ parameters.taskTestStep }}:coverage inputs: targetType: inline workingDirectory: $(Pipeline.Workspace)/${{ parameters.buildDirectory }} script: | set -eu -o pipefail npm run ${{ parameters.taskTestStep }}:coverage condition: and(succeededOrFailed(), eq(variables['startTest'], 'true')) env: # Tests can use this environment variable to behave differently when running from a test branch ${{ if contains(parameters.taskTestStep, 'tinylicious') }}: # Disable colorization for tinylicious logs (not useful when printing to a file) logger__colorize: "false" # Need to pass it as string so ADO doesn't convert it into False (capital F) which doesn't work logger__morganFormat: tiny # Test - No coverage - ${{ else }}: - task: Bash@3 displayName: npm run ${{ parameters.taskTestStep }} inputs: targetType: inline workingDirectory: $(Pipeline.Workspace)/${{ parameters.buildDirectory }} script: | set -eu -o pipefail npm run ${{ parameters.taskTestStep }} condition: and(succeededOrFailed(), eq(variables['startTest'], 'true')) env: # Tests can use this environment variable to behave differently when running from a test branch ${{ if contains(parameters.taskTestStep, 'tinylicious') }}: # Disable colorization for tinylicious logs (not useful when printing to a file) logger__colorize: "false" # Need to pass it as string so ADO doesn't convert it into False (capital F) which doesn't work logger__morganFormat: tiny