import Store from "electron-store" ; import { mocked } from "ts-jest/utils" ; jest . mock ( "electron-store" ) ; const mockedStore = mocked ( Store ) ; class MockStore < O extends Record < PropertyKey , any > > { private store : O = { } as any ; get = < K extends keyof O > ( key , defaultValue ? ) => this . store [ key ] ?? defaultValue ! ; set = < K extends keyof O > ( key , value ) => { this . store [ key ] = value ; } ; delete = < K extends keyof O > ( key ) => { delete this . store [ key ] ; } ; has = ( key ) => key in this . store ; clear = ( ) => { this . store = { } as any ; } ; get size ( ) { return Object . keys ( this . store ) . length ; } path = "PATH_TO_STORE" ; } mockedStore . mockImplementation ( ( ) : any => new MockStore ( ) ) ;