UNPKG

nightwatch

Version:

Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.

25 lines (24 loc) 686 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Cdp { async getConnection(driver, reset = false) { if (!reset && this._connection) { return this._connection; } return this._connection = await driver.createCDPConnection('page'); } resetConnection() { this._connection = undefined; this._networkMocks = undefined; } get networkMocks() { if (this._networkMocks) { return this._networkMocks; } return this._networkMocks = {}; } addNetworkMock(url, response) { this.networkMocks[url] = response; } } module.exports = new Cdp();