Skip to content

Commit 8a5778d

Browse files
committed
Convert new integration tests to jest and add to CI
1 parent 0963f18 commit 8a5778d

24 files changed

+931
-756
lines changed

Diff for: .vscode/launch.json

-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138
],
139139
"env": {
140140
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
141-
"OSVC_SUITE": "slnWithCsproj",
142141
},
143142
"sourceMaps": true,
144143
"outFiles": [

Diff for: azure-pipelines.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,28 @@ stages:
3838
strategy:
3939
matrix:
4040
linux:
41-
demandsName: ImageOverride -equals Build.Ubuntu.2204.Amd64.Open
41+
demandsName: 1es-ubuntu-2004-open
4242
windows:
43-
demandsName: ImageOverride -equals 1es-windows-2022-open
43+
demandsName: 1es-windows-2022-open
4444
pool:
4545
name: NetCore-Public
46-
demands: $(demandsName)
46+
demands: ImageOverride -equals $(demandsName)
4747
steps:
4848
- template: azure-pipelines/test.yml
4949

50-
- stage: Test_Omnisharp
51-
displayName: Test Omnisharp
50+
- stage: Test_OmniSharp
51+
displayName: Test OmniSharp
5252
dependsOn: []
5353
jobs:
5454
- job: Test
5555
strategy:
5656
matrix:
5757
linux:
58-
demandsName: ImageOverride -equals Build.Ubuntu.2204.Amd64.Open
58+
demandsName: 1es-ubuntu-2004-open
59+
windows:
60+
demandsName: 1es-windows-2022-open
5961
pool:
6062
name: NetCore-Public
61-
demands: $(demandsName)
63+
demands: ImageOverride -equals $(demandsName)
6264
steps:
6365
- template: azure-pipelines/test-omnisharp.yml

Diff for: azure-pipelines/test-omnisharp.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ steps:
77

88
- template: prereqs.yml
99

10-
- pwsh: |
11-
if ($IsLinux) {
12-
Write-Host "Activating screen emulation"
13-
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
14-
$env:DISPLAY=':99.0'
15-
Write-Host "Now running tests"
16-
}
10+
- template: test-prereqs.yml
1711

18-
npm run omnisharptest
12+
- script: npm run omnisharptest
1913
displayName: 🧪 Run unit and integration tests
14+
env:
15+
DISPLAY: :99.0
2016

2117
- task: PublishPipelineArtifact@1
2218
condition: failed()
2319
displayName: 'Upload integration test logs'
2420
inputs:
2521
targetPath: '$(Build.SourcesDirectory)/.vscode-test/user-data/logs'
26-
artifactName: 'VSCode Test Logs ($(Agent.JobName)-$(System.JobAttempt))'
22+
artifactName: 'VSCode Test OmniSharp Logs ($(Agent.JobName)-$(System.JobAttempt))'

Diff for: azure-pipelines/test-prereqs.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
steps:
2+
3+
# We need to download the roslyn language server for the current platform to run integration tests against it.
4+
- script: gulp installDependencies
5+
displayName: 'Install Roslyn Language Server'
6+
7+
- script: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
8+
displayName: 'Activate screen emulation'
9+
condition: eq(variables['Agent.OS'], 'Linux')

Diff for: azure-pipelines/test.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ steps:
77

88
- template: prereqs.yml
99

10-
- pwsh: |
11-
if ($IsLinux) {
12-
Write-Host "Activating screen emulation"
13-
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
14-
$env:DISPLAY=':99.0'
15-
Write-Host "Now running tests"
16-
}
10+
- template: test-prereqs.yml
1711

18-
npm run test
12+
- script: npm run test
1913
displayName: 🧪 Run unit and integration tests
14+
env:
15+
DISPLAY: :99.0
2016

2117
- task: PublishPipelineArtifact@1
2218
condition: failed()

Diff for: baseJestConfig.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import type { Config } from 'jest';
6+
7+
/**
8+
* Defines a base project config that we can re-use across the project specific jest configs.
9+
* We do this because jest generally does not inherit project configuration settings.
10+
*/
11+
export const baseProjectConfig: Config = {
12+
preset: 'ts-jest',
13+
testEnvironment: 'node',
14+
transformIgnorePatterns: ['/dist/.+\\.js'],
15+
};

Diff for: jest.config.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,11 @@
55
import type { Config } from 'jest';
66

77
const config: Config = {
8-
verbose: true,
9-
preset: 'ts-jest',
10-
testEnvironment: 'node',
11-
transformIgnorePatterns: ['/dist/.+\\.js'],
12-
// We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module,
13-
// the TS version from the __mocks__ directory and the compiled js version from the out directory.
14-
modulePathIgnorePatterns: ['out'],
15-
// Specify jest to only run tests in jest folders.
16-
// We also have to include the __mocks__ folder. That folder must be next to node_modules so we can't move it,
17-
// but if we specify roots, jest won't automatically pick it up. So we have to specify it here.
18-
roots: ['<rootDir>/test/unitTests', '<rootDir>/omnisharptest/omnisharpJestTests', '<rootDir>/__mocks__'],
8+
projects: [
9+
'<rootDir>/test/unitTests/jest.config.ts',
10+
'<rootDir>/test/integrationTests/jest.config.ts',
11+
'<rootDir>/omnisharptest/omnisharpJestTests/jest.config.ts',
12+
],
1913
};
2014

2115
export default config;

Diff for: omnisharptest/omnisharpJestTests/jest.config.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import type { Config } from 'jest';
6+
import { baseProjectConfig } from '../../baseJestConfig';
7+
8+
export const jestOmniSharpUnitTestProjectName = 'OmniSharp Unit Tests';
9+
10+
/**
11+
* Defines a jest project configuration for O# jest tests.
12+
*/
13+
const omnisharpConfig: Config = {
14+
...baseProjectConfig,
15+
displayName: jestOmniSharpUnitTestProjectName,
16+
// We need to explicity ignore the out directory for modules - otherwise we'll get duplicate vscode module,
17+
// the TS version from the __mocks__ directory and the compiled js version from the out directory.
18+
modulePathIgnorePatterns: ['out'],
19+
// Specify jest to only run tests in jest folders.
20+
// We also have to include the __mocks__ folder. That folder must be next to node_modules so we can't move it,
21+
// but if we specify roots, jest won't automatically pick it up. So we have to specify it here.
22+
roots: ['<rootDir>', '<rootDir>/../../__mocks__'],
23+
};
24+
25+
export default omnisharpConfig;

0 commit comments

Comments
 (0)