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