beforeEach(async () => {
        request.mockClear()

        browser = await remote({
            baseUrl: 'http://foobar.com',
            capabilities: {
                browserName: 'foobar'
            }
        })
    })
Пример #2
0
        it('should retry and eventually respond', async () => {
            const req = new WebDriverRequest('POST', '/session')
            req.emit = jest.fn()

            request.mockClear()
            const opts = Object.assign(req.defaultOptions, { uri: { path: '/wd/hub/failing' }, body: { foo: 'bar' } })
            expect(await req._request(opts, 3)).toEqual({ value: 'caught' })
            expect(req.emit.mock.calls).toHaveLength(4)
            expect(logger().warn.mock.calls).toHaveLength(3)
            expect(logger().error.mock.calls).toHaveLength(0)
        })
Пример #3
0
        it('should short circuit if request throws a stale element exception', async () => {
            const req = new WebDriverRequest('POST', 'session/:sessionId/element')
            req.emit = jest.fn()

            const opts = Object.assign(req.defaultOptions, {
                uri: { path: '/wd/hub/session/foobar-123/element/some-sub-sub-elem-231/click' }, body: { foo: 'bar' } })

            let error
            try {
                await req._request(opts)
            } catch (e) {
                error = e
            }

            expect(error.message).toBe('element is not attached to the page document')
            expect(req.emit.mock.calls).toHaveLength(1)
            expect(warn.mock.calls).toHaveLength(1)
            expect(warn.mock.calls).toEqual([['Request encountered a stale element - terminating request']])

            request.retryCnt = 0
            warn.mockClear()
            request.mockClear()
        })
Пример #4
0
 beforeEach(() => {
     request.mockClear()
 })
Пример #5
0
afterEach(() => {
    request.mockClear()
})
Пример #6
0
 afterEach(() => {
     request.mockClear()
     request.resetSessionId()
     request.setMockResponse()
 })