5
5
6
6
import * as vscode from 'vscode' ;
7
7
import * as path from 'path' ;
8
- import * as jestLib from '@jest/globals' ;
8
+ import { describe , beforeAll , beforeEach , afterAll , test , expect } from '@jest/globals' ;
9
9
import testAssetWorkspace from './testAssets/testAssetWorkspace' ;
10
10
import { activateCSharpExtension , openFileInWorkspaceAsync } from './integrationHelpers' ;
11
11
import { TestProgress } from '../../src/lsptoolshost/roslynProtocol' ;
12
12
13
- jestLib . describe ( `[${ testAssetWorkspace . description } ] Test Unit Testing` , function ( ) {
14
- jestLib . beforeAll ( async function ( ) {
13
+ describe ( `[${ testAssetWorkspace . description } ] Test Unit Testing` , function ( ) {
14
+ beforeAll ( async function ( ) {
15
15
await activateCSharpExtension ( ) ;
16
16
} ) ;
17
17
18
- jestLib . beforeEach ( async function ( ) {
18
+ beforeEach ( async function ( ) {
19
19
vscode . workspace
20
20
. getConfiguration ( )
21
21
. update ( 'dotnet.unitTests.runSettingsPath' , undefined , vscode . ConfigurationTarget . Workspace ) ;
22
22
const fileName = path . join ( 'test' , 'UnitTest1.cs' ) ;
23
23
await openFileInWorkspaceAsync ( fileName ) ;
24
24
} ) ;
25
25
26
- jestLib . afterAll ( async ( ) => {
26
+ afterAll ( async ( ) => {
27
27
await testAssetWorkspace . cleanupWorkspace ( ) ;
28
28
} ) ;
29
29
30
- jestLib . test ( 'Unit test code lens items are displayed' , async ( ) => {
30
+ test ( 'Unit test code lens items are displayed' , async ( ) => {
31
31
const codeLenses = await getCodeLensesAsync ( ) ;
32
- jestLib . expect ( codeLenses ) . toHaveLength ( 9 ) ;
32
+ expect ( codeLenses ) . toHaveLength ( 9 ) ;
33
33
34
34
const classRange = new vscode . Range ( new vscode . Position ( 5 , 17 ) , new vscode . Position ( 5 , 26 ) ) ;
35
35
36
36
// Class level debug all tests
37
- jestLib . expect ( codeLenses [ 1 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
38
- jestLib . expect ( codeLenses [ 1 ] . command ?. title ) . toBe ( 'Debug All Tests' ) ;
39
- jestLib . expect ( codeLenses [ 1 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
40
- jestLib . expect ( codeLenses [ 1 ] . range ) . toStrictEqual ( classRange ) ;
37
+ expect ( codeLenses [ 1 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
38
+ expect ( codeLenses [ 1 ] . command ?. title ) . toBe ( 'Debug All Tests' ) ;
39
+ expect ( codeLenses [ 1 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
40
+ expect ( codeLenses [ 1 ] . range ) . toStrictEqual ( classRange ) ;
41
41
42
42
// Class level run all tests
43
- jestLib . expect ( codeLenses [ 2 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
44
- jestLib . expect ( codeLenses [ 2 ] . command ?. title ) . toBe ( 'Run All Tests' ) ;
45
- jestLib . expect ( codeLenses [ 2 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
46
- jestLib . expect ( codeLenses [ 2 ] . range ) . toStrictEqual ( classRange ) ;
43
+ expect ( codeLenses [ 2 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
44
+ expect ( codeLenses [ 2 ] . command ?. title ) . toBe ( 'Run All Tests' ) ;
45
+ expect ( codeLenses [ 2 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
46
+ expect ( codeLenses [ 2 ] . range ) . toStrictEqual ( classRange ) ;
47
47
48
48
let methodRange = new vscode . Range ( new vscode . Position ( 8 , 20 ) , new vscode . Position ( 8 , 25 ) ) ;
49
49
// Method level run and debug test
50
- jestLib . expect ( codeLenses [ 4 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
51
- jestLib . expect ( codeLenses [ 4 ] . command ?. title ) . toBe ( 'Debug Test' ) ;
52
- jestLib . expect ( codeLenses [ 4 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
53
- jestLib . expect ( codeLenses [ 4 ] . range ) . toStrictEqual ( methodRange ) ;
54
- jestLib . expect ( codeLenses [ 5 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
55
- jestLib . expect ( codeLenses [ 5 ] . command ?. title ) . toBe ( 'Run Test' ) ;
56
- jestLib . expect ( codeLenses [ 5 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
57
- jestLib . expect ( codeLenses [ 5 ] . range ) . toStrictEqual ( methodRange ) ;
50
+ expect ( codeLenses [ 4 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
51
+ expect ( codeLenses [ 4 ] . command ?. title ) . toBe ( 'Debug Test' ) ;
52
+ expect ( codeLenses [ 4 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
53
+ expect ( codeLenses [ 4 ] . range ) . toStrictEqual ( methodRange ) ;
54
+ expect ( codeLenses [ 5 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
55
+ expect ( codeLenses [ 5 ] . command ?. title ) . toBe ( 'Run Test' ) ;
56
+ expect ( codeLenses [ 5 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
57
+ expect ( codeLenses [ 5 ] . range ) . toStrictEqual ( methodRange ) ;
58
58
59
59
methodRange = new vscode . Range ( new vscode . Position ( 15 , 20 ) , new vscode . Position ( 15 , 25 ) ) ;
60
- jestLib . expect ( codeLenses [ 7 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
61
- jestLib . expect ( codeLenses [ 7 ] . command ?. title ) . toBe ( 'Debug Test' ) ;
62
- jestLib . expect ( codeLenses [ 7 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
63
- jestLib . expect ( codeLenses [ 7 ] . range ) . toStrictEqual ( methodRange ) ;
64
- jestLib . expect ( codeLenses [ 8 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
65
- jestLib . expect ( codeLenses [ 8 ] . command ?. title ) . toBe ( 'Run Test' ) ;
66
- jestLib . expect ( codeLenses [ 8 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
67
- jestLib . expect ( codeLenses [ 8 ] . range ) . toStrictEqual ( methodRange ) ;
60
+ expect ( codeLenses [ 7 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
61
+ expect ( codeLenses [ 7 ] . command ?. title ) . toBe ( 'Debug Test' ) ;
62
+ expect ( codeLenses [ 7 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( true ) ;
63
+ expect ( codeLenses [ 7 ] . range ) . toStrictEqual ( methodRange ) ;
64
+ expect ( codeLenses [ 8 ] . command ?. command ) . toBe ( 'dotnet.test.run' ) ;
65
+ expect ( codeLenses [ 8 ] . command ?. title ) . toBe ( 'Run Test' ) ;
66
+ expect ( codeLenses [ 8 ] . command ?. arguments ! [ 0 ] . attachDebugger ) . toBe ( false ) ;
67
+ expect ( codeLenses [ 8 ] . range ) . toStrictEqual ( methodRange ) ;
68
68
} ) ;
69
69
70
- jestLib . test ( 'Code lens command executes tests' , async ( ) => {
70
+ test ( 'Code lens command executes tests' , async ( ) => {
71
71
const codeLenses = await getCodeLensesAsync ( ) ;
72
- jestLib . expect ( codeLenses ) . toHaveLength ( 9 ) ;
72
+ expect ( codeLenses ) . toHaveLength ( 9 ) ;
73
73
74
74
const runAllTestsCommand = codeLenses [ 2 ] . command ! ;
75
- jestLib . expect ( runAllTestsCommand . title ) . toBe ( 'Run All Tests' ) ;
75
+ expect ( runAllTestsCommand . title ) . toBe ( 'Run All Tests' ) ;
76
76
77
77
const testResults = await vscode . commands . executeCommand < TestProgress | undefined > (
78
78
runAllTestsCommand . command ,
79
79
runAllTestsCommand . arguments ! [ 0 ]
80
80
) ;
81
- jestLib . expect ( testResults ) . toBeDefined ( ) ;
82
- jestLib . expect ( testResults ?. totalTests ) . toEqual ( 2 ) ;
83
- jestLib . expect ( testResults ?. testsPassed ) . toEqual ( 2 ) ;
84
- jestLib . expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
85
- jestLib . expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
81
+ expect ( testResults ) . toBeDefined ( ) ;
82
+ expect ( testResults ?. totalTests ) . toEqual ( 2 ) ;
83
+ expect ( testResults ?. testsPassed ) . toEqual ( 2 ) ;
84
+ expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
85
+ expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
86
86
} ) ;
87
87
88
- jestLib . test ( 'dotnet.test.runTestsInContext executes tests' , async ( ) => {
88
+ test ( 'dotnet.test.runTestsInContext executes tests' , async ( ) => {
89
89
const activeEditor = vscode . window . activeTextEditor ;
90
90
if ( ! activeEditor ) {
91
91
throw new Error ( 'No active editor' ) ;
@@ -97,31 +97,31 @@ jestLib.describe(`[${testAssetWorkspace.description}] Test Unit Testing`, functi
97
97
'dotnet.test.runTestsInContext' ,
98
98
activeEditor
99
99
) ;
100
- jestLib . expect ( testResults ) . toBeDefined ( ) ;
101
- jestLib . expect ( testResults ?. totalTests ) . toEqual ( 1 ) ;
102
- jestLib . expect ( testResults ?. testsPassed ) . toEqual ( 1 ) ;
103
- jestLib . expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
104
- jestLib . expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
100
+ expect ( testResults ) . toBeDefined ( ) ;
101
+ expect ( testResults ?. totalTests ) . toEqual ( 1 ) ;
102
+ expect ( testResults ?. testsPassed ) . toEqual ( 1 ) ;
103
+ expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
104
+ expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
105
105
} ) ;
106
106
107
- jestLib . test ( 'Run tests uses .runsettings' , async ( ) => {
107
+ test ( 'Run tests uses .runsettings' , async ( ) => {
108
108
await vscode . workspace . getConfiguration ( ) . update ( 'dotnet.unitTests.runSettingsPath' , '.runsettings' ) ;
109
109
110
110
const codeLenses = await getCodeLensesAsync ( ) ;
111
- jestLib . expect ( codeLenses ) . toHaveLength ( 9 ) ;
111
+ expect ( codeLenses ) . toHaveLength ( 9 ) ;
112
112
113
113
const runAllTestsCommand = codeLenses [ 2 ] . command ! ;
114
- jestLib . expect ( runAllTestsCommand . title ) . toBe ( 'Run All Tests' ) ;
114
+ expect ( runAllTestsCommand . title ) . toBe ( 'Run All Tests' ) ;
115
115
116
116
const testResults = await vscode . commands . executeCommand < TestProgress | undefined > (
117
117
runAllTestsCommand . command ,
118
118
runAllTestsCommand . arguments ! [ 0 ]
119
119
) ;
120
- jestLib . expect ( testResults ) . toBeDefined ( ) ;
121
- jestLib . expect ( testResults ?. totalTests ) . toEqual ( 1 ) ;
122
- jestLib . expect ( testResults ?. testsPassed ) . toEqual ( 1 ) ;
123
- jestLib . expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
124
- jestLib . expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
120
+ expect ( testResults ) . toBeDefined ( ) ;
121
+ expect ( testResults ?. totalTests ) . toEqual ( 1 ) ;
122
+ expect ( testResults ?. testsPassed ) . toEqual ( 1 ) ;
123
+ expect ( testResults ?. testsFailed ) . toEqual ( 0 ) ;
124
+ expect ( testResults ?. testsSkipped ) . toEqual ( 0 ) ;
125
125
} ) ;
126
126
} ) ;
127
127
0 commit comments