Skip to content

Commit 7789914

Browse files
committed
test: switch expect to jest
1 parent 8909666 commit 7789914

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

test/commands/acc-transformer/transform.nut.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
'use strict';
33

44
import { resolve } from 'node:path';
5-
import { describe, it } from '@jest/globals';
5+
import { describe, it, expect } from '@jest/globals';
66

77
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
8-
import { expect } from 'chai';
98
import { formatOptions } from '../../../src/utils/constants.js';
109
import { inputJsons, invalidJson } from '../../utils/testConstants.js';
1110
import { compareToBaselines } from '../../utils/baselineCompare.js';
@@ -33,7 +32,7 @@ describe('acc-transformer transform NUTs', () => {
3332
const command = `acc-transformer transform --coverage-json "${path}" --output-report "${reportPath}" --format ${format} -i "samples"`;
3433
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
3534

36-
expect(output.replace('\n', '')).to.equal(`The coverage report has been written to ${reportPath}`);
35+
expect(output.replace('\n', '')).toStrictEqual(`The coverage report has been written to ${reportPath}`);
3736
});
3837
});
3938
});
@@ -46,7 +45,7 @@ describe('acc-transformer transform NUTs', () => {
4645
const command = `acc-transformer transform --coverage-json "${invalidJson}"`;
4746
const error = execCmd(command, { ensureExitCode: 1 }).shellOutput.stderr;
4847

49-
expect(error.replace('\n', '')).to.contain(
48+
expect(error.replace('\n', '')).toContain(
5049
'The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.'
5150
);
5251
});

test/commands/acc-transformer/transform.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-disable no-await-in-loop */
22
'use strict';
33
import { resolve } from 'node:path';
4-
import { describe, it } from '@jest/globals';
4+
import { describe, it, expect } from '@jest/globals';
55

66
import { TestContext } from '@salesforce/core/testSetup';
7-
import { expect } from 'chai';
87
import { transformCoverageReport } from '../../../src/transformers/coverageTransformer.js';
98
import { formatOptions } from '../../../src/utils/constants.js';
109
import { getCoverageHandler } from '../../../src/handlers/getHandler.js';
@@ -48,7 +47,7 @@ describe('main', () => {
4847
throw new Error('Command did not fail as expected');
4948
} catch (error) {
5049
if (error instanceof Error) {
51-
expect(error.message).to.include(
50+
expect(error.message).toContain(
5251
'The provided JSON does not match a known coverage data format from the Salesforce deploy or test command.'
5352
);
5453
} else {
@@ -62,27 +61,27 @@ describe('main', () => {
6261
throw new Error('Command did not fail as expected');
6362
} catch (error) {
6463
if (error instanceof Error) {
65-
expect(error.message).to.include('Unsupported format: invalid');
64+
expect(error.message).toContain('Unsupported format: invalid');
6665
} else {
6766
throw new Error('An unknown error type was thrown.');
6867
}
6968
}
7069
});
7170
it('confirms a warning with a JSON file that does not exist.', async () => {
7271
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.');
7473
});
7574
it('ignore a package directory and produce a warning on the deploy command report.', async () => {
7675
const result = await transformCoverageReport(deployCoverage, 'coverage.xml', 'sonar', [
7776
'packaged',
7877
'force-app',
7978
'samples',
8079
]);
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.');
8281
});
8382
it('ignore a package directory and produce a warning on the test command report.', async () => {
8483
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.');
8685
});
8786
it('test where a statementMap has a non-object value.', async () => {
8887
const invalidDeployData = {
@@ -100,7 +99,7 @@ describe('main', () => {
10099
};
101100

102101
const result = checkCoverageDataType(invalidDeployData as unknown as DeployCoverageData);
103-
expect(result).to.equal('Unknown');
102+
expect(result).toStrictEqual('Unknown');
104103
});
105104
it('create a cobertura report using only 1 package directory', async () => {
106105
await transformCoverageReport(deployCoverage, 'coverage.xml', 'cobertura', ['packaged', 'force-app']);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect } from 'chai';
1+
import { expect } from '@jest/globals';
22
import { checkCoverageDataType } from '../../../src/utils/setCoverageDataType.js';
33
import { DeployCoverageData } from '../../../src/utils/types.js';
44

@@ -7,13 +7,13 @@ describe('isSingleTestCoverageData - non-object element', () => {
77
const data = [123]; // Not an object
88

99
const result = checkCoverageDataType(data as unknown as DeployCoverageData);
10-
expect(result).to.equal('Unknown');
10+
expect(result).toStrictEqual('Unknown');
1111
});
1212
});
1313

1414
describe('isDeployCoverageData - non-object', () => {
1515
it('returns Unknown when data is not an object', () => {
1616
const result = checkCoverageDataType(42 as unknown as DeployCoverageData); // 👈 non-object input
17-
expect(result).to.equal('Unknown');
17+
expect(result).toStrictEqual('Unknown');
1818
});
1919
});

0 commit comments

Comments
 (0)