2022-05-19 01:06:14 -08:00
|
|
|
import { vi } from 'vitest'
|
|
|
|
|
const SevereServiceErrorImport = await vi.importActual('../packages/webdriverio/src/utils/SevereServiceError') as { default: any }
|
2020-07-01 15:09:43 -08:00
|
|
|
|
2020-03-29 23:46:53 -08:00
|
|
|
const getWdioMock = () => {
|
|
|
|
|
const mock = {
|
2022-05-19 01:06:14 -08:00
|
|
|
$: vi.fn(),
|
|
|
|
|
$$: vi.fn(),
|
|
|
|
|
debug: vi.fn(),
|
|
|
|
|
on: vi.fn(),
|
2020-03-29 23:46:53 -08:00
|
|
|
sessionId: 'fakeid',
|
2022-11-29 15:43:53 -09:00
|
|
|
addCommand: vi.fn(),
|
|
|
|
|
overwriteCommand: vi.fn(),
|
2022-05-19 01:06:14 -08:00
|
|
|
react$: vi.fn(),
|
|
|
|
|
react$$: vi.fn(),
|
|
|
|
|
custom$: vi.fn(),
|
|
|
|
|
deleteSession: vi.fn()
|
2020-03-29 23:46:53 -08:00
|
|
|
}
|
2020-12-02 20:34:42 -09:00
|
|
|
mock.deleteSession.mockReturnValue(Promise.resolve(mock))
|
2020-03-29 23:46:53 -08:00
|
|
|
|
|
|
|
|
return mock
|
2018-11-12 12:31:33 -09:00
|
|
|
}
|
|
|
|
|
|
2022-05-19 01:06:14 -08:00
|
|
|
export const attach = vi.fn().mockImplementation(() => (getWdioMock()))
|
|
|
|
|
export const remote = vi.fn().mockImplementation(() => {
|
2020-12-02 20:34:42 -09:00
|
|
|
if ((global as any).throwRemoteCall) {
|
2019-02-26 02:04:36 -09:00
|
|
|
throw new Error('boom')
|
|
|
|
|
}
|
2020-03-29 23:46:53 -08:00
|
|
|
return getWdioMock()
|
2019-02-26 02:04:36 -09:00
|
|
|
})
|
2022-05-19 01:06:14 -08:00
|
|
|
export const multiremote = vi.fn().mockImplementation(() => (getWdioMock()))
|
2020-07-01 15:09:43 -08:00
|
|
|
|
2020-12-02 20:34:42 -09:00
|
|
|
export const SevereServiceError = SevereServiceErrorImport.default
|