1
1
/* eslint-disable no-await-in-loop */
2
2
'use strict' ;
3
3
import { resolve } from 'node:path' ;
4
- import { describe , it } from '@jest/globals' ;
4
+ import { describe , it , expect } from '@jest/globals' ;
5
5
6
6
import { TestContext } from '@salesforce/core/testSetup' ;
7
- import { expect } from 'chai' ;
8
7
import { transformCoverageReport } from '../../../src/transformers/coverageTransformer.js' ;
9
8
import { formatOptions } from '../../../src/utils/constants.js' ;
10
9
import { getCoverageHandler } from '../../../src/handlers/getHandler.js' ;
@@ -48,7 +47,7 @@ describe('main', () => {
48
47
throw new Error ( 'Command did not fail as expected' ) ;
49
48
} catch ( error ) {
50
49
if ( error instanceof Error ) {
51
- expect ( error . message ) . to . include (
50
+ expect ( error . message ) . toContain (
52
51
'The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.'
53
52
) ;
54
53
} else {
@@ -62,27 +61,27 @@ describe('main', () => {
62
61
throw new Error ( 'Command did not fail as expected' ) ;
63
62
} catch ( error ) {
64
63
if ( error instanceof Error ) {
65
- expect ( error . message ) . to . include ( 'Unsupported format: invalid' ) ;
64
+ expect ( error . message ) . toContain ( 'Unsupported format: invalid' ) ;
66
65
} else {
67
66
throw new Error ( 'An unknown error type was thrown.' ) ;
68
67
}
69
68
}
70
69
} ) ;
71
70
it ( 'confirms a warning with a JSON file that does not exist.' , async ( ) => {
72
71
const result = await transformCoverageReport ( 'nonexistent.json' , 'coverage.xml' , 'sonar' , [ ] ) ;
73
- expect ( result . warnings ) . to . include ( 'Failed to read nonexistent.json. Confirm file exists.' ) ;
72
+ expect ( result . warnings ) . toContain ( 'Failed to read nonexistent.json. Confirm file exists.' ) ;
74
73
} ) ;
75
74
it ( 'ignore a package directory and produce a warning on the deploy command report.' , async ( ) => {
76
75
const result = await transformCoverageReport ( deployCoverage , 'coverage.xml' , 'sonar' , [
77
76
'packaged' ,
78
77
'force-app' ,
79
78
'samples' ,
80
79
] ) ;
81
- expect ( result . warnings ) . to . include ( 'The file name AccountTrigger was not found in any package directory.' ) ;
80
+ expect ( result . warnings ) . toContain ( 'The file name AccountTrigger was not found in any package directory.' ) ;
82
81
} ) ;
83
82
it ( 'ignore a package directory and produce a warning on the test command report.' , async ( ) => {
84
83
const result = await transformCoverageReport ( testCoverage , 'coverage.xml' , 'sonar' , [ 'packaged' , 'samples' ] ) ;
85
- expect ( result . warnings ) . to . include ( 'The file name AccountTrigger was not found in any package directory.' ) ;
84
+ expect ( result . warnings ) . toContain ( 'The file name AccountTrigger was not found in any package directory.' ) ;
86
85
} ) ;
87
86
it ( 'test where a statementMap has a non-object value.' , async ( ) => {
88
87
const invalidDeployData = {
@@ -100,7 +99,7 @@ describe('main', () => {
100
99
} ;
101
100
102
101
const result = checkCoverageDataType ( invalidDeployData as unknown as DeployCoverageData ) ;
103
- expect ( result ) . to . equal ( 'Unknown' ) ;
102
+ expect ( result ) . toStrictEqual ( 'Unknown' ) ;
104
103
} ) ;
105
104
it ( 'create a cobertura report using only 1 package directory' , async ( ) => {
106
105
await transformCoverageReport ( deployCoverage , 'coverage.xml' , 'cobertura' , [ 'packaged' , 'force-app' ] ) ;
0 commit comments