|
| 1 | +parameters: |
| 2 | +- name: serviceConnection |
| 3 | + type: string |
| 4 | +- name: testProjectDirectory |
| 5 | + type: string |
| 6 | +- name: testProjectName |
| 7 | + type: string |
| 8 | +- name: testfileDirectory |
| 9 | + type: string |
| 10 | + |
| 11 | +steps: |
| 12 | +- task: DeleteFiles@1 |
| 13 | + displayName: 'Clean Build Directory' |
| 14 | + inputs: |
| 15 | + SourceFolder: '$(System.DefaultWorkingDirectory)' |
| 16 | + Contents: | |
| 17 | + **/bin/* |
| 18 | + **/obj/* |
| 19 | + **/TestResults/* |
| 20 | + **/drop/* |
| 21 | + RemoveSourceFolder: false |
| 22 | + |
| 23 | +- task: PowerShell@2 |
| 24 | + displayName: 'Copy Test Files' |
| 25 | + inputs: |
| 26 | + targetType: 'inline' |
| 27 | + script: | |
| 28 | + $sourcePath = "$(System.DefaultWorkingDirectory)/${{ parameters.testProjectDirectory }}/${{parameters.testfileDirectory}}" |
| 29 | + $targetPath = "$(Build.ArtifactStagingDirectory)/TestFiles" |
| 30 | +
|
| 31 | + Write-Host "Source path: $sourcePath" |
| 32 | + Write-Host "Target path: $targetPath" |
| 33 | +
|
| 34 | + # Check if the source directory exists |
| 35 | + if (!(Test-Path -Path $sourcePath)) { |
| 36 | + Write-Error "Source directory not found: $sourcePath" |
| 37 | + exit 1 |
| 38 | + } |
| 39 | +
|
| 40 | + # Create the target directory if it doesn't exist |
| 41 | + if (!(Test-Path -Path $targetPath)) { |
| 42 | + New-Item -ItemType Directory -Path $targetPath -Force |
| 43 | + } |
| 44 | +
|
| 45 | + # Copy the files |
| 46 | + Copy-Item -Path "$sourcePath\*" -Destination $targetPath -Recurse -Force |
| 47 | +
|
| 48 | + # Verify files were copied |
| 49 | + Write-Host "Files copied to target directory:" |
| 50 | + Get-ChildItem -Path $targetPath -Recurse | ForEach-Object { Write-Host $_.FullName } |
| 51 | +
|
| 52 | +- task: PublishBuildArtifacts@1 |
| 53 | + displayName: 'Publish Test Files' |
| 54 | + inputs: |
| 55 | + PathtoPublish: '$(Build.ArtifactStagingDirectory)' |
| 56 | + ArtifactName: 'TestFiles' |
| 57 | + publishLocation: 'Container' |
| 58 | + |
| 59 | +- script: | |
| 60 | + export AZURE_IDENTITY_DISABLE_MANAGED_IDENTITY=true |
| 61 | + displayName: 'Export Identity Config' |
| 62 | + |
| 63 | +- task: NodeTool@0 |
| 64 | + displayName: 'Install Node.js' |
| 65 | + inputs: |
| 66 | + versionSpec: '22.x' |
| 67 | + |
| 68 | +- script: | |
| 69 | + npm install |
| 70 | + displayName: 'Install npm dependencies' |
| 71 | + workingDirectory: '$(System.DefaultWorkingDirectory)/${{ parameters.testProjectDirectory }}' |
| 72 | + |
| 73 | +- script: | |
| 74 | + echo "Current working directory:" |
| 75 | + pwd |
| 76 | + echo "Contents of the directory:" |
| 77 | + ls -la |
| 78 | + echo "Running tests..." |
| 79 | + npm test |
| 80 | + displayName: 'Run Tests' |
| 81 | + workingDirectory: '$(System.DefaultWorkingDirectory)/${{ parameters.testProjectDirectory }}' |
| 82 | + env: |
| 83 | + CONTAINER_NAME: $(CONTAINER_NAME) |
| 84 | + Is_CloudEnvironment: $(Is_CloudEnvironment) |
| 85 | + CAASFOLDER_STORAGE_CONNECTION_STRING: $(CAASFOLDER_STORAGE_CONNECTION_STRING) |
| 86 | + ENDPOINT_COHORT_DISTRIBUTION_DATA_SERVICE: $(ENDPOINT_COHORT_DISTRIBUTION_DATA_SERVICE) |
| 87 | + ENDPOINT_PARTICIPANT_MANAGEMENT_DATA_SERVICE: $(ENDPOINT_PARTICIPANT_MANAGEMENT_DATA_SERVICE) |
| 88 | + ENDPOINT_EXCEPTION_MANAGEMENT_DATA_SERVICE: $(ENDPOINT_EXCEPTION_MANAGEMENT_DATA_SERVICE) |
| 89 | + |
| 90 | +- task: PublishBuildArtifacts@1 |
| 91 | + displayName: 'Publish Playwright Test Reports' |
| 92 | + inputs: |
| 93 | + PathtoPublish: '$(System.DefaultWorkingDirectory)/${{ parameters.testProjectDirectory }}/src/config/playwright-report' |
| 94 | + ArtifactName: 'PlaywrightHTMLReport' |
| 95 | + publishLocation: 'Container' |
0 commit comments