Skip to content

Commit 32c463c

Browse files
committed
test: reduce error logging in the console for failed test to avoid confusion in CI logs
Signed-off-by: Lenin Mehedy <[email protected]>
1 parent 3012780 commit 32c463c

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/core/helm.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Helm extends ShellRunner {
4444
* @returns {Promise<Array>} console output as an array of strings
4545
*/
4646
async install (...args) {
47-
return this.run(this.prepareCommand('install', ...args), true)
47+
return this.run(this.prepareCommand('install', ...args))
4848
}
4949

5050
/**

test/e2e/commands/cluster.test.mjs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ import {
2020
beforeEach,
2121
describe,
2222
expect,
23-
it
23+
it, jest
2424
} from '@jest/globals'
2525
import {
2626
bootstrapTestVariables,
2727
getDefaultArgv,
2828
TEST_CLUSTER
2929
} from '../../test_util.js'
3030
import {
31-
constants
31+
constants,
32+
logging
3233
} from '../../../src/core/index.mjs'
3334
import { flags } from '../../../src/commands/index.mjs'
3435
import { sleep } from '../../../src/core/helpers.mjs'
3536
import * as version from '../../../version.mjs'
3637

3738
describe('ClusterCommand', () => {
39+
// mock showUser and showJSON to silent logging during tests
40+
jest.spyOn(logging.Logger.prototype, 'showUser').mockImplementation()
41+
jest.spyOn(logging.Logger.prototype, 'showJSON').mockImplementation()
42+
3843
const testName = 'cluster-cmd-e2e'
3944
const namespace = testName
4045
const argv = getDefaultArgv()
@@ -75,7 +80,6 @@ describe('ClusterCommand', () => {
7580
try {
7681
await expect(clusterCmd.reset(argv)).resolves.toBeTruthy()
7782
} catch (e) {
78-
clusterCmd.logger.showUserError(e)
7983
expect(e).toBeNull()
8084
}
8185
}
@@ -89,7 +93,6 @@ describe('ClusterCommand', () => {
8993
try {
9094
await expect(clusterCmd.setup(argv)).rejects.toThrowError('Error on cluster setup')
9195
} catch (e) {
92-
clusterCmd.logger.showUserError(e)
9396
expect(e).toBeNull()
9497
}
9598
}, 60000)
@@ -102,7 +105,6 @@ describe('ClusterCommand', () => {
102105
try {
103106
await expect(clusterCmd.setup(argv)).resolves.toBeTruthy()
104107
} catch (e) {
105-
clusterCmd.logger.showUserError(e)
106108
expect(e).toBeNull()
107109
}
108110
}, 60000)
@@ -111,7 +113,6 @@ describe('ClusterCommand', () => {
111113
try {
112114
await expect(clusterCmd.getClusterInfo()).resolves.toBeTruthy()
113115
} catch (e) {
114-
clusterCmd.logger.showUserError(e)
115116
expect(e).toBeNull()
116117
}
117118
}, 60000)
@@ -120,7 +121,6 @@ describe('ClusterCommand', () => {
120121
try {
121122
await expect(clusterCmd.showClusterList()).resolves.toBeTruthy()
122123
} catch (e) {
123-
clusterCmd.logger.showUserError(e)
124124
expect(e).toBeNull()
125125
}
126126
}, 60000)
@@ -129,7 +129,6 @@ describe('ClusterCommand', () => {
129129
try {
130130
await expect(clusterCmd.showInstalledChartList()).resolves.toBeUndefined()
131131
} catch (e) {
132-
clusterCmd.logger.showUserError(e)
133132
expect(e).toBeNull()
134133
}
135134
}, 60000)
@@ -156,7 +155,6 @@ describe('ClusterCommand', () => {
156155
try {
157156
await expect(clusterCmd.reset(argv)).resolves.toBeTruthy()
158157
} catch (e) {
159-
clusterCmd.logger.showUserError(e)
160158
expect(e).toBeNull()
161159
}
162160
}, 60000)

test/unit/core/helm.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe.each([
3030

3131
it('should run helm install', async () => {
3232
await helm.install('arg')
33-
expect(shellSpy).toHaveBeenCalledWith(`${helmPath} install arg`, true)
33+
expect(shellSpy).toHaveBeenCalledWith(`${helmPath} install arg`)
3434
})
3535

3636
it('should run helm uninstall', async () => {

0 commit comments

Comments
 (0)