Skip to content

Commit

Permalink
feat: consider concise feature for test setup section (#407)
Browse files Browse the repository at this point in the history
* feat: consider concise feature for test setup section

* chore: bump core
  • Loading branch information
CristiCanizales authored Jul 17, 2024
1 parent edfc527 commit 8d50228
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "lib/src/index.js",
"dependencies": {
"@jsforce/jsforce-node": "^3.2.3",
"@salesforce/core": "^8.1.2",
"@salesforce/core": "^8.2.0",
"@salesforce/kit": "^3.1.6",
"@types/istanbul-reports": "^3.0.4",
"bfj": "8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/humanFormatTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class HumanFormatTransform extends Readable {
this.formatCodeCov();
}
}
if (this.testResult.setup) {
if (this.testResult.setup && !this.concise) {
this.formatSetup();
}
this.formatSummary();
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/humanReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class HumanReporter {
tbResult += this.formatCodeCov(testResult.codecoverage);
}
}
if (testResult.setup) {
if (testResult.setup && !concise) {
tbResult += this.formatSetup(testResult);
}
tbResult += this.formatSummary(testResult);
Expand Down
6 changes: 6 additions & 0 deletions src/tests/asyncTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ export class AsyncTests {
}
}

/**
* @returns A connection based on the current api version and the max api version.
*/
public async defineApiVersion(): Promise<Connection> {
const maxApiVersion = await this.connection.retrieveMaxApiVersion();

Expand All @@ -536,6 +539,9 @@ export class AsyncTests {
return this.connection;
}

/**
* @returns A new connection similar to the current one but with a new api version.
*/
public async cloneConnectionWithNewVersion(
newVersion: string
): Promise<Connection> {
Expand Down
13 changes: 13 additions & 0 deletions test/reporters/humanFormatTransform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe('HumanFormatTransform', () => {
expect(result).to.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.contain('AccountServiceTest.setup_method 24');
expect(result).to.contain('Test Setup Time 24 ms');
expect(result).to.contain('Test Total Time 5487 ms');
});
Expand All @@ -104,11 +105,23 @@ describe('HumanFormatTransform', () => {
expect(result).to.not.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.not.contain('AccountServiceTest.setup_method 24');
expect(result).to.contain('Test Setup Time 0 ms');
expect(result).to.contain('Test Total Time 5463 ms');
});
});

it('should not display test setup summary if concise is true', () => {
const reporter = new HumanFormatTransform(setupResult, false, true);
createWritableAndPipeline(reporter, (result) => {
expect(result).to.not.be.empty;
expect(result).to.not.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.not.contain('AccountServiceTest.setup_method 24');
});
});

it('should format test results with detailed coverage specified', () => {
const reporter = new HumanFormatTransform(coverageResult, true);
createWritableAndPipeline(reporter, (result) => {
Expand Down
11 changes: 11 additions & 0 deletions test/reporters/humanReporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('Human Reporter Tests', () => {
expect(result).to.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.contain('AccountServiceTest.setup_method 24');
expect(result).to.contain('Test Setup Time 24 ms');
expect(result).to.contain('Test Total Time 5487 ms');
});
Expand All @@ -73,10 +74,20 @@ describe('Human Reporter Tests', () => {
expect(result).to.not.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.not.contain('AccountServiceTest.setup_method 24');
expect(result).to.contain('Test Setup Time 0 ms');
expect(result).to.contain('Test Total Time 5463 ms');
});

it('should not display test setup summary if concise is true', () => {
const result = reporter.format(setupResult, false, true);
expect(result).to.not.be.empty;
expect(result).to.not.contain(
'=== Test Setup Time by Test Class for Run 7073t000061uwZI'
);
expect(result).to.not.contain('AccountServiceTest.setup_method 24');
});

it('should format test results with detailed coverage specified', () => {
const result = reporter.format(coverageResult, true);
expect(result).to.not.be.empty;
Expand Down
30 changes: 5 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -474,26 +474,6 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@jsforce/jsforce-node@^3.2.1":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.2.2.tgz#6bc1bf483f52023d63ae76534fc8665b2df215e0"
integrity sha512-wQl4iCkwbop3eJfl+PxgFfIEPE2Ka68MvgnxbxVX/yx+NhfiNqbl08uKLAG+VcI40D8sgApfm86Yx7o8Q9PZmw==
dependencies:
"@sindresorhus/is" "^4"
"@types/node" "^18.15.3"
abort-controller "^3.0.0"
base64url "^3.0.1"
csv-parse "^5.5.2"
csv-stringify "^6.4.4"
faye "^1.4.0"
form-data "^4.0.0"
fs-extra "^8.1.0"
https-proxy-agent "^5.0.0"
multistream "^3.1.0"
node-fetch "^2.6.1"
strip-ansi "^6.0.0"
xml2js "^0.6.2"

"@jsforce/jsforce-node@^3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@jsforce/jsforce-node/-/jsforce-node-3.2.3.tgz#9758cfe3ce7a2d884a621b5eb9b69db8eeb79da4"
Expand Down Expand Up @@ -540,12 +520,12 @@
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==

"@salesforce/core@^8.1.2":
version "8.1.2"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.1.2.tgz#0c6c39c8bd97607a9577d3c5823e0ff6fba18fa0"
integrity sha512-g54tw9BY1CAHopchk4tGPd66Aws0IEGB682R4mfBYN4aVPRbzmAH720gDBIH5xj3u+eXXekGbgHk0lYr73jgRQ==
"@salesforce/core@^8.2.0":
version "8.2.0"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-8.2.0.tgz#34a5600c799a960c10f5d7a5920a3b7c50c7df28"
integrity sha512-qe4dz1fuaWBKOVz2pTCBEtz6i1EXM96fO1xZ/AYg/pEbhWY79D8jiSDNaIkCYeq2FHH0AUvbSwFox+37qvq6NA==
dependencies:
"@jsforce/jsforce-node" "^3.2.1"
"@jsforce/jsforce-node" "^3.2.3"
"@salesforce/kit" "^3.1.6"
"@salesforce/schemas" "^1.9.0"
"@salesforce/ts-types" "^2.0.10"
Expand Down

0 comments on commit 8d50228

Please sign in to comment.