Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: testresult mapping of source deployment #610

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const mapTestResults = <T extends Failures | Successes>(testResults: T[])
fullName: testResult.name,
id: testResult.id,
...('message' in testResult && testResult.message
? { message: testResult.message, outcome: ApexTestResultOutcome.Pass }
: { message: null, outcome: ApexTestResultOutcome.Fail }),
? { message: testResult.message, outcome: ApexTestResultOutcome.Fail }
: { message: null, outcome: ApexTestResultOutcome.Pass }),
methodName: testResult.methodName,
queueItemId: '',
runTime: parseInt(testResult.time, 10),
Expand Down
57 changes: 57 additions & 0 deletions test/utils/coverage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { expect } from 'chai';
import { ApexTestResultOutcome } from '@salesforce/apex-node';
import { mapTestResults } from '../../src/utils/coverage';

describe('coverage utils', () => {
describe('mapTestResultsTests', () => {
it('should map result without a message to a succeeded test', () => {
const resultsArray = mapTestResults([
{
id: 'myId',
methodName: 'mySuccessMethod',
name: 'myName',
time: '42',
},
]);
expect(resultsArray).to.have.length(1);

const result = resultsArray[0];

expect(result.outcome).to.be.eq(ApexTestResultOutcome.Pass);
expect(result.message).to.be.null;
expect(result.fullName).to.be.eq('myName');
expect(result.methodName).to.be.eq('mySuccessMethod');
expect(result.runTime).to.be.eq(42);
});

it('should map result with a message to a failed test', () => {
const resultsArray = mapTestResults([
{
id: 'myId',
methodName: 'myFailedMethod',
name: 'myName',
time: '42',
message: 'Something went wrong',
stackTrace: 'SomeStackTrace',
},
]);
expect(resultsArray).to.have.length(1);

const result = resultsArray[0];

expect(result.outcome).to.be.eq(ApexTestResultOutcome.Fail);
expect(result.message).to.be.eq('Something went wrong');
expect(result.fullName).to.be.eq('myName');
expect(result.methodName).to.be.eq('myFailedMethod');
expect(result.runTime).to.be.eq(42);
expect(result.stackTrace).to.be.eq('SomeStackTrace');
});
});
});