@wdio/repl 9.0.0-alpha.78 → 9.0.0

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.
package/build/index.d.ts CHANGED
@@ -28,8 +28,6 @@
28
28
  * @type utility
29
29
  *
30
30
  */
31
- /// <reference types="node" resolution-mode="require"/>
32
- /// <reference types="node" resolution-mode="require"/>
33
31
  import vm from 'node:vm';
34
32
  import repl from 'node:repl';
35
33
  export interface ReplConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,MAAM,CAAC,YAAY,SAAgB;IACnC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,WAAW,CAA6B;gBAEpC,MAAM,CAAC,EAAE,UAAU;IAQ/B,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,YAAY;IAe5F,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,aAAa;IA2CrB,KAAK,CAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO;CAkB9B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,MAAM,CAAC,YAAY,SAAgB;IACnC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,WAAW,CAA6B;gBAEpC,MAAM,CAAC,EAAE,UAAU;IAQ/B,IAAI,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,YAAY;IAe5F,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,aAAa;IA2CrB,KAAK,CAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO;CAkB9B"}
package/build/index.js CHANGED
@@ -1,114 +1,108 @@
1
- /**
2
- *
3
- * This command helps you to debug your integration tests. It stops the running browser and gives
4
- * you time to jump into it and check the state of your application (e.g. using dev tools).
5
- * Your terminal transforms into a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
6
- * interface that will allow you to try out certain commands, find elements and test actions on
7
- * them.
8
- *
9
- * [![WebdriverIO REPL](https://webdriver.io/img/repl.gif)](https://webdriver.io/img/repl.gif)
10
- *
11
- * If you run the WDIO testrunner make sure you increase the timeout property of the test framework
12
- * you are using (e.g. Mocha or Jasmine) in order to prevent test termination due to a test timeout.
13
- * Also avoid executing the command with multiple capabilities running at the same time.
14
- *
15
- * <iframe width="560" height="315" src="https://www.youtube.com/embed/xWwP-3B_YyE" frameBorder="0" allowFullScreen></iframe>
16
- *
17
- * <example>
18
- :debug.js
19
- it('should demonstrate the debug command', () => {
20
- $('#input').setValue('FOO')
21
- browser.debug() // jumping into the browser and change value of #input to 'BAR'
22
- const value = $('#input').getValue()
23
- console.log(value) // outputs: "BAR"
24
- })
25
- * </example>
26
- *
27
- * @alias browser.debug
28
- * @type utility
29
- *
30
- */
31
- import vm from 'node:vm';
32
- import repl from 'node:repl';
33
- import { STATIC_RETURNS, INTRO_MESSAGE, DEFAULT_CONFIG } from './constants.js';
34
- export default class WDIORepl {
35
- static introMessage = INTRO_MESSAGE;
36
- _config;
37
- _isCommandRunning = false;
38
- _replServer;
39
- constructor(config) {
40
- this._config = Object.assign(DEFAULT_CONFIG, { eval: this.eval.bind(this) }, config);
1
+ // src/index.ts
2
+ import vm from "node:vm";
3
+ import repl from "node:repl";
4
+
5
+ // src/constants.ts
6
+ var STATIC_RETURNS = {
7
+ driver: "[WebdriverIO REPL client]",
8
+ browser: "[WebdriverIO REPL client]",
9
+ $: "[Function: findElement]",
10
+ $$: "[Function: findElements]"
11
+ };
12
+ var INTRO_MESSAGE = `
13
+ The execution has stopped!
14
+ You can now go into the browser or use the command line as REPL
15
+ (To exit, press ^C again or type .exit)
16
+ `;
17
+ var DEFAULT_CONFIG = {
18
+ commandTimeout: 5e3,
19
+ prompt: "\u203A ",
20
+ useGlobal: true,
21
+ useColor: true
22
+ };
23
+
24
+ // src/index.ts
25
+ var WDIORepl = class {
26
+ static introMessage = INTRO_MESSAGE;
27
+ _config;
28
+ _isCommandRunning = false;
29
+ _replServer;
30
+ constructor(config) {
31
+ this._config = Object.assign(
32
+ DEFAULT_CONFIG,
33
+ { eval: this.eval.bind(this) },
34
+ config
35
+ );
36
+ }
37
+ eval(cmd, context, filename, callback) {
38
+ if (this._isCommandRunning) {
39
+ return;
41
40
  }
42
- eval(cmd, context, filename, callback) {
43
- if (this._isCommandRunning) {
44
- return;
45
- }
46
- if (cmd && STATIC_RETURNS[cmd.trim()]) {
47
- return callback(null, STATIC_RETURNS[cmd.trim()]);
48
- }
49
- vm.createContext(context);
50
- this._isCommandRunning = true;
51
- return this._runCmd(cmd, context, callback);
41
+ if (cmd && STATIC_RETURNS[cmd.trim()]) {
42
+ return callback(null, STATIC_RETURNS[cmd.trim()]);
52
43
  }
53
- _runCmd(cmd, context, callback) {
54
- try {
55
- const result = vm.runInContext(cmd, context);
56
- return this._handleResult(result, callback);
57
- }
58
- catch (e) {
59
- this._isCommandRunning = false;
60
- return callback(e, undefined);
61
- }
44
+ vm.createContext(context);
45
+ this._isCommandRunning = true;
46
+ return this._runCmd(cmd, context, callback);
47
+ }
48
+ _runCmd(cmd, context, callback) {
49
+ try {
50
+ const result = vm.runInContext(cmd, context);
51
+ return this._handleResult(result, callback);
52
+ } catch (e) {
53
+ this._isCommandRunning = false;
54
+ return callback(e, void 0);
62
55
  }
63
- _handleResult(result, callback) {
64
- if (!result || typeof result.then !== 'function') {
65
- this._isCommandRunning = false;
66
- return callback(null, result);
67
- }
68
- let timeoutCalled = false;
69
- const timeout = setTimeout(() => {
70
- callback(new Error('Command execution timed out'), undefined);
71
- this._isCommandRunning = false;
72
- timeoutCalled = true;
73
- }, this._config.commandTimeout);
74
- result.then((res) => {
75
- /**
76
- * don't do anything if timeout was called
77
- */
78
- if (timeoutCalled) {
79
- return;
80
- }
81
- this._isCommandRunning = false;
82
- clearTimeout(timeout);
83
- return callback(null, res);
84
- }, (e) => {
85
- /**
86
- * don't do anything if timeout was called
87
- */
88
- if (timeoutCalled) {
89
- return;
90
- }
91
- this._isCommandRunning = false;
92
- clearTimeout(timeout);
93
- const errorMessage = e ? e.message : 'Command execution timed out';
94
- const commandError = new Error(errorMessage);
95
- delete commandError.stack;
96
- return callback(commandError, undefined);
97
- });
56
+ }
57
+ _handleResult(result, callback) {
58
+ if (!result || typeof result.then !== "function") {
59
+ this._isCommandRunning = false;
60
+ return callback(null, result);
98
61
  }
99
- start(context) {
100
- if (this._replServer) {
101
- throw new Error('a repl was already initialized');
102
- }
103
- if (context) {
104
- const evalFn = this._config.eval;
105
- this._config.eval = function (cmd, _, filename, callback) {
106
- return evalFn.call(this, cmd, context, filename, callback);
107
- };
108
- }
109
- this._replServer = repl.start(this._config);
110
- return new Promise((resolve) => {
111
- return this._replServer.on('exit', resolve);
112
- });
62
+ let timeoutCalled = false;
63
+ const timeout = setTimeout(
64
+ () => {
65
+ callback(new Error("Command execution timed out"), void 0);
66
+ this._isCommandRunning = false;
67
+ timeoutCalled = true;
68
+ },
69
+ this._config.commandTimeout
70
+ );
71
+ result.then((res) => {
72
+ if (timeoutCalled) {
73
+ return;
74
+ }
75
+ this._isCommandRunning = false;
76
+ clearTimeout(timeout);
77
+ return callback(null, res);
78
+ }, (e) => {
79
+ if (timeoutCalled) {
80
+ return;
81
+ }
82
+ this._isCommandRunning = false;
83
+ clearTimeout(timeout);
84
+ const errorMessage = e ? e.message : "Command execution timed out";
85
+ const commandError = new Error(errorMessage);
86
+ delete commandError.stack;
87
+ return callback(commandError, void 0);
88
+ });
89
+ }
90
+ start(context) {
91
+ if (this._replServer) {
92
+ throw new Error("a repl was already initialized");
113
93
  }
114
- }
94
+ if (context) {
95
+ const evalFn = this._config.eval;
96
+ this._config.eval = function(cmd, _, filename, callback) {
97
+ return evalFn.call(this, cmd, context, filename, callback);
98
+ };
99
+ }
100
+ this._replServer = repl.start(this._config);
101
+ return new Promise((resolve) => {
102
+ return this._replServer.on("exit", resolve);
103
+ });
104
+ }
105
+ };
106
+ export {
107
+ WDIORepl as default
108
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/repl",
3
- "version": "9.0.0-alpha.78+fee2f8a88",
3
+ "version": "9.0.0",
4
4
  "description": "A WDIO helper utility to provide a repl interface for WebdriverIO",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-repl",
@@ -25,8 +25,10 @@
25
25
  "type": "module",
26
26
  "types": "./build/index.d.ts",
27
27
  "exports": {
28
- ".": "./build/index.js",
29
- "./package.json": "./package.json"
28
+ ".": {
29
+ "import": "./build/index.js",
30
+ "types": "./build/index.d.ts"
31
+ }
30
32
  },
31
33
  "typeScriptVersion": "3.8.3",
32
34
  "dependencies": {
@@ -35,5 +37,5 @@
35
37
  "publishConfig": {
36
38
  "access": "public"
37
39
  },
38
- "gitHead": "fee2f8a88d132537795eaf144abf1a7e242f99ff"
40
+ "gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
39
41
  }
@@ -1,17 +0,0 @@
1
- export const STATIC_RETURNS = {
2
- driver: '[WebdriverIO REPL client]',
3
- browser: '[WebdriverIO REPL client]',
4
- $: '[Function: findElement]',
5
- $$: '[Function: findElements]'
6
- };
7
- export const INTRO_MESSAGE = `
8
- The execution has stopped!
9
- You can now go into the browser or use the command line as REPL
10
- (To exit, press ^C again or type .exit)
11
- `;
12
- export const DEFAULT_CONFIG = {
13
- commandTimeout: 5000,
14
- prompt: '\u203A ',
15
- useGlobal: true,
16
- useColor: true
17
- };
File without changes