test: do not mock console globally

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
Maksim Sukharev
2025-06-20 17:20:15 +02:00
parent 4f3866cf9c
commit 44cf9e818c
4 changed files with 2 additions and 17 deletions

View File

@ -47,7 +47,6 @@ module.exports = {
setupFiles: [],
setupFilesAfterEnv: [
'<rootDir>/src/test-setup.js',
'jest-mock-console/dist/setupTestFramework.js',
],
globalSetup: resolve(__dirname, 'jest.global.setup.js'),

View File

@ -5,7 +5,6 @@ import { getUploader } from '@nextcloud/upload'
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { createLocalVue } from '@vue/test-utils'
import mockConsole from 'jest-mock-console'
import { cloneDeep } from 'lodash'
import { createPinia, setActivePinia } from 'pinia'
import Vuex from 'vuex'
@ -66,7 +65,6 @@ describe('fileUploadStore', () => {
})
describe('uploading', () => {
let restoreConsole
const uploadMock = jest.fn()
const client = {
exists: jest.fn(),
@ -75,13 +73,13 @@ describe('fileUploadStore', () => {
beforeEach(() => {
storeConfig.getters.getAttachmentFolder = jest.fn().mockReturnValue(() => '/Talk')
store = new Vuex.Store(storeConfig)
restoreConsole = mockConsole(['error', 'debug'])
getDavClient.mockReturnValue(client)
getUploader.mockReturnValue({ upload: uploadMock })
console.error = jest.fn()
})
afterEach(() => {
restoreConsole()
jest.clearAllMocks()
})
test('initialises upload for given files', () => {
@ -271,7 +269,6 @@ describe('fileUploadStore', () => {
reason: 'failed-upload',
})
expect(showError).toHaveBeenCalled()
expect(console.error).toHaveBeenCalled()
})
test('marks temporary message as failed in case of sharing error', async () => {

View File

@ -6,7 +6,6 @@ import { emit } from '@nextcloud/event-bus'
import { createLocalVue } from '@vue/test-utils'
import Hex from 'crypto-js/enc-hex.js'
import SHA1 from 'crypto-js/sha1.js'
import mockConsole from 'jest-mock-console'
import { cloneDeep } from 'lodash'
import { createPinia, setActivePinia } from 'pinia'
import Vuex from 'vuex'
@ -877,16 +876,10 @@ describe('participantsStore', () => {
})
describe('force join on error', () => {
let restoreConsole
beforeEach(() => {
restoreConsole = mockConsole(['error', 'debug'])
})
afterEach(() => {
jest.useRealTimers()
expect(SessionStorage.getItem('joined_conversation')).toBe(null)
expect(joinedConversationEventMock).not.toHaveBeenCalled()
restoreConsole()
})
/**

View File

@ -3,7 +3,6 @@ import { showError } from '@nextcloud/dialogs'
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import mockConsole from 'jest-mock-console'
import { createPinia, setActivePinia } from 'pinia'
import { useTalkHashStore } from '../talkHash.js'
@ -13,16 +12,13 @@ jest.mock('@nextcloud/dialogs', () => ({
describe('talkHashStore', () => {
let talkHashStore
let restoreConsole
beforeEach(() => {
setActivePinia(createPinia())
talkHashStore = useTalkHashStore()
restoreConsole = mockConsole(['debug'])
})
afterEach(() => {
restoreConsole()
})
afterEach(() => {