fix: only mock the cpus() function on the os module instead of the whole module

This commit is contained in:
Daniel Kennedy authored and Salman Muin Kayser Chishti committed 2025-10-15 16:26:39 +01:00
1 parent 27b1fd90ee
commit 9ade3233e3
1 file changed
+8 -4
+8 -4
View File
@@ -1,10 +1,14 @@
import * as config from '../src/internal/shared/config'
import os from 'os'
// Mock the 'os' module
jest.mock('os', () => ({
cpus: jest.fn()
}))
// Mock the `cpus()` function in the `os` module
jest.mock('os', () => {
const osActual = jest.requireActual('os')
return {
...osActual,
cpus: jest.fn()
}
})
beforeEach(() => {
jest.resetModules()