@wdio/webdriver-mock-service 7.20.7 → 7.20.8-alpha.504

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const nock_1 = __importDefault(require("nock"));
7
- const protocols_1 = require("@wdio/protocols");
1
+ import nock from 'nock';
2
+ import { WebDriverProtocol, MJsonWProtocol, JsonWProtocol, AppiumProtocol, ChromiumProtocol, SauceLabsProtocol, SeleniumProtocol } from '@wdio/protocols';
8
3
  const REGEXP_SESSION_ID = /\/[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}/;
9
4
  const SESSION_ID = 'XXX';
10
5
  const protocols = [
11
- protocols_1.JsonWProtocol, protocols_1.WebDriverProtocol, protocols_1.MJsonWProtocol, protocols_1.AppiumProtocol,
12
- protocols_1.ChromiumProtocol, protocols_1.SauceLabsProtocol, protocols_1.SeleniumProtocol
6
+ JsonWProtocol, WebDriverProtocol, MJsonWProtocol, AppiumProtocol,
7
+ ChromiumProtocol, SauceLabsProtocol, SeleniumProtocol
13
8
  ];
14
9
  const protocolFlattened = new Map();
15
10
  for (const protocol of protocols) {
@@ -19,10 +14,13 @@ for (const protocol of protocols) {
19
14
  }
20
15
  }
21
16
  }
22
- class WebDriverMock {
17
+ export default class WebDriverMock {
18
+ path;
19
+ command;
20
+ scope;
23
21
  constructor(host = 'localhost', port = 4444, path = '/') {
24
22
  this.path = path;
25
- this.scope = (0, nock_1.default)(`http://${host}:${port}`, { 'encodedQueryParams': true });
23
+ this.scope = nock(`http://${host}:${port}`, { 'encodedQueryParams': true });
26
24
  this.command = new Proxy({}, { get: this.get.bind(this) });
27
25
  }
28
26
  /**
@@ -85,4 +83,3 @@ class WebDriverMock {
85
83
  };
86
84
  }
87
85
  }
88
- exports.default = WebDriverMock;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NO_SUCH_ELEMENT = void 0;
4
- exports.NO_SUCH_ELEMENT = {
1
+ export const NO_SUCH_ELEMENT = {
5
2
  value: {
6
3
  error: 'no such element',
7
4
  message: 'Unable to locate element: bodys',
package/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Services } from '@wdio/types';
2
2
  import type { Browser, MultiRemoteBrowser } from 'webdriverio';
3
- import WebDriverMock from './WebDriverMock';
3
+ import WebDriverMock from './WebDriverMock.js';
4
4
  export default class WebdriverMockService implements Services.ServiceInstance {
5
5
  private _browser?;
6
6
  private _mock;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAW3C,MAAM,CAAC,OAAO,OAAO,oBAAqB,YAAW,QAAQ,CAAC,eAAe;IACzE,OAAO,CAAC,QAAQ,CAAC,CAAgD;IACjE,OAAO,CAAC,KAAK,CAAsB;;IAMnC,IAAI;IAgBJ,MAAM,CACF,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAuB3D,aAAa;IAQb,kBAAkB;IASlB,qBAAqB;IAKrB,sBAAsB;IAYtB,wBAAwB;IAUxB,6BAA6B;IAU7B,2BAA2B;IA+B3B,sBAAsB;IAOtB,iCAAiC;IAQjC,gBAAgB;IAShB,qBAAqB,CAAC,KAAK,SAAI;IAa/B,sBAAsB;IAUtB,wBAAwB;IASxB,gBAAgB;IAShB,SAAS;CAIZ;AAED;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAE9D,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAW9C,MAAM,CAAC,OAAO,OAAO,oBAAqB,YAAW,QAAQ,CAAC,eAAe;IACzE,OAAO,CAAC,QAAQ,CAAC,CAAgD;IACjE,OAAO,CAAC,KAAK,CAAsB;;IAMnC,IAAI;IAgBJ,MAAM,CACF,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAuB3D,aAAa;IAQb,kBAAkB;IASlB,qBAAqB;IAKrB,sBAAsB;IAYtB,wBAAwB;IAUxB,6BAA6B;IAU7B,2BAA2B;IA+B3B,sBAAsB;IAOtB,iCAAiC;IAQjC,gBAAgB;IAShB,qBAAqB,CAAC,KAAK,SAAI;IAa/B,sBAAsB;IAUtB,wBAAwB;IASxB,gBAAgB;IAShB,SAAS;CAIZ;AAED;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,CAAA"}
package/build/index.js CHANGED
@@ -1,32 +1,26 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WebDriverMock = void 0;
7
- const nock_1 = __importDefault(require("nock"));
8
- const uuid_1 = require("uuid");
9
- const WebDriverMock_1 = __importDefault(require("./WebDriverMock"));
10
- exports.WebDriverMock = WebDriverMock_1.default;
11
- const constants_1 = require("./constants");
12
- const newSession_1 = require("./mocks/newSession");
1
+ import nock from 'nock';
2
+ import { v4 as uuidv4 } from 'uuid';
3
+ import WebDriverMock from './WebDriverMock.js';
4
+ import { NO_SUCH_ELEMENT } from './constants.js';
5
+ import { newSession, deleteSession } from './mocks/newSession.js';
13
6
  const ELEMENT_ID = '401c0039-3306-6a46-a98d-f5939870a249';
14
7
  const ELEMENT_REFETCHED = '80d860d0-b829-f540-812e-7078eb983795';
15
8
  const ELEMENT_ALT = '8bf4d107-a363-40d1-b823-d94bdbc58afb';
16
9
  const ELEM_PROP = 'element-6066-11e4-a52e-4f735466cecf';
17
- class WebdriverMockService {
10
+ export default class WebdriverMockService {
11
+ _browser;
12
+ _mock = new WebDriverMock();
18
13
  constructor() {
19
- this._mock = new WebDriverMock_1.default();
20
14
  this.init();
21
15
  }
22
16
  init() {
23
17
  // define required responses
24
18
  this._mock.command.status().times(Infinity).reply(200, { value: {} });
25
19
  this._mock.command.newSession().times(Infinity).reply(200, () => {
26
- newSession_1.newSession.value.sessionId = (0, uuid_1.v4)();
27
- return newSession_1.newSession;
20
+ newSession.value.sessionId = uuidv4();
21
+ return newSession;
28
22
  });
29
- this._mock.command.deleteSession().times(2).reply(200, newSession_1.deleteSession);
23
+ this._mock.command.deleteSession().times(2).reply(200, deleteSession);
30
24
  this._mock.command.getTitle().times(Infinity).reply(200, { value: 'Mock Page Title' });
31
25
  this._mock.command.getUrl().times(Infinity).reply(200, { value: 'https://mymockpage.com' });
32
26
  this._mock.command.getElementRect(ELEMENT_ID).times(2).reply(200, { value: { width: 1, height: 2, x: 3, y: 4 } });
@@ -69,12 +63,12 @@ class WebdriverMockService {
69
63
  }
70
64
  isNotExistingScenario() {
71
65
  this.nockReset();
72
- this._mock.command.findElement().reply(404, constants_1.NO_SUCH_ELEMENT);
66
+ this._mock.command.findElement().reply(404, NO_SUCH_ELEMENT);
73
67
  }
74
68
  waitForElementScenario() {
75
69
  this.nockReset();
76
70
  const elemResponse = { [ELEM_PROP]: ELEMENT_ID };
77
- this._mock.command.findElement().once().reply(404, constants_1.NO_SUCH_ELEMENT);
71
+ this._mock.command.findElement().once().reply(404, NO_SUCH_ELEMENT);
78
72
  this._mock.command.findElement().times(2).reply(200, { value: elemResponse });
79
73
  this._mock.command.findElements().times(5).reply(200, { value: [] });
80
74
  this._mock.command.findElements().reply(200, { value: [elemResponse] });
@@ -83,14 +77,14 @@ class WebdriverMockService {
83
77
  isNeverDisplayedScenario() {
84
78
  this.nockReset();
85
79
  const elemResponse = { [ELEM_PROP]: ELEMENT_ID };
86
- this._mock.command.findElement().times(2).reply(404, constants_1.NO_SUCH_ELEMENT);
80
+ this._mock.command.findElement().times(2).reply(404, NO_SUCH_ELEMENT);
87
81
  this._mock.command.findElement().times(2).reply(200, { value: elemResponse });
88
82
  this._mock.command.isElementDisplayed(ELEMENT_ID).once().reply(200, { value: true });
89
83
  }
90
84
  isEventuallyDisplayedScenario() {
91
85
  this.nockReset();
92
86
  const elemResponse = { [ELEM_PROP]: ELEMENT_ID };
93
- this._mock.command.findElement().times(1).reply(404, constants_1.NO_SUCH_ELEMENT);
87
+ this._mock.command.findElement().times(1).reply(404, NO_SUCH_ELEMENT);
94
88
  this._mock.command.findElement().times(2).reply(200, { value: elemResponse });
95
89
  this._mock.command.isElementDisplayed(ELEMENT_ID).once().reply(200, { value: true });
96
90
  }
@@ -101,7 +95,7 @@ class WebdriverMockService {
101
95
  //Found initially
102
96
  this._mock.command.findElement().once().reply(200, { value: elemResponse });
103
97
  //Initiate refetch, but its not ready
104
- this._mock.command.findElement().once().reply(404, constants_1.NO_SUCH_ELEMENT);
98
+ this._mock.command.findElement().once().reply(404, NO_SUCH_ELEMENT);
105
99
  //Always return the new element after
106
100
  this._mock.command.findElement().times(4).reply(200, { value: elem2Response });
107
101
  //First click works
@@ -173,8 +167,11 @@ class WebdriverMockService {
173
167
  this._mock.command.elementClick(ELEMENT_ID).reply(200, { value: null });
174
168
  }
175
169
  nockReset() {
176
- nock_1.default.cleanAll();
170
+ nock.cleanAll();
177
171
  this.init();
178
172
  }
179
173
  }
180
- exports.default = WebdriverMockService;
174
+ /**
175
+ * export for 3rd party usage
176
+ */
177
+ export { WebDriverMock };
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteSession = exports.newSession = void 0;
4
- exports.newSession = {
1
+ export const newSession = {
5
2
  value: {
6
3
  sessionId: 'undefined',
7
4
  capabilities: {
@@ -26,6 +23,6 @@ exports.newSession = {
26
23
  }
27
24
  }
28
25
  };
29
- exports.deleteSession = {
26
+ export const deleteSession = {
30
27
  value: null
31
28
  };
package/package.json CHANGED
@@ -1,33 +1,36 @@
1
1
  {
2
2
  "name": "@wdio/webdriver-mock-service",
3
- "version": "7.20.7",
3
+ "version": "7.20.8-alpha.504+428a9d729",
4
4
  "description": "A WebdriverIO service to stub all endpoints for internal testing purposes.",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-webdriver-mock-service",
7
7
  "license": "MIT",
8
- "main": "./build/index",
9
8
  "engines": {
10
- "node": ">=12.0.0"
9
+ "node": "^16.13 || >=18"
11
10
  },
12
11
  "repository": {
13
12
  "type": "git",
14
- "url": "git://github.com/webdriverio/webdriverio.git"
13
+ "url": "git://github.com/webdriverio/webdriverio.git",
14
+ "directory": "packages/wdio-webdriver-mock-service"
15
15
  },
16
16
  "keywords": [],
17
17
  "bugs": {
18
18
  "url": "https://github.com/webdriverio/webdriverio/issues"
19
19
  },
20
+ "type": "module",
21
+ "exports": "./build/index.js",
22
+ "types": "./build/index.d.ts",
23
+ "typeScriptVersion": "3.8.3",
20
24
  "dependencies": {
21
- "@types/uuid": "^8.3.0",
22
- "@wdio/protocols": "7.20.6",
23
- "@wdio/types": "7.20.7",
24
- "nock": "^13.0.0",
25
- "uuid": "^8.0.0",
26
- "webdriverio": "7.20.7"
25
+ "@types/uuid": "^8.3.4",
26
+ "@wdio/protocols": "7.20.8-alpha.504+428a9d729",
27
+ "@wdio/types": "7.20.8-alpha.504+428a9d729",
28
+ "nock": "^13.2.4",
29
+ "uuid": "^9.0.0",
30
+ "webdriverio": "7.20.8-alpha.504+428a9d729"
27
31
  },
28
32
  "publishConfig": {
29
33
  "access": "public"
30
34
  },
31
- "types": "./build/index.d.ts",
32
- "gitHead": "21b8b61453f4749d87eca3e4d7d6e5e2cb60f043"
35
+ "gitHead": "428a9d729ae6231968a60908732fa3f607d195e9"
33
36
  }