@appium/test-support 3.0.53 → 3.1.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/README.md +0 -89
- package/build/lib/index.d.ts +0 -2
- package/build/lib/index.js +1 -5
- package/build/lib/index.js.map +1 -1
- package/lib/index.js +0 -2
- package/package.json +3 -3
- package/build/lib/env-utils.d.ts +0 -5
- package/build/lib/env-utils.d.ts.map +0 -1
- package/build/lib/env-utils.js +0 -18
- package/build/lib/env-utils.js.map +0 -1
- package/build/lib/log-utils.d.ts +0 -34
- package/build/lib/log-utils.d.ts.map +0 -1
- package/build/lib/log-utils.js +0 -50
- package/build/lib/log-utils.js.map +0 -1
- package/lib/env-utils.js +0 -16
- package/lib/log-utils.js +0 -51
package/README.md
CHANGED
|
@@ -13,50 +13,6 @@ npm install @appium/test-support --save-dev
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
### stubEnv
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
import { stubEnv } from '@appium/test-support';
|
|
20
|
-
|
|
21
|
-
describe('myTest', () => {
|
|
22
|
-
stubEnv();
|
|
23
|
-
it('setting env variable', () => {
|
|
24
|
-
// Changes to process.env will stay local
|
|
25
|
-
process.env.ABC = 'abc';
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### stubLog
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import { stubLog } from '@appium/test-support';
|
|
34
|
-
|
|
35
|
-
describe('myTest', () => {
|
|
36
|
-
let sandbox;
|
|
37
|
-
// configure sandbox here...
|
|
38
|
-
|
|
39
|
-
it('stubbing log', () => {
|
|
40
|
-
let logStub = stubLog(sandbox, log);
|
|
41
|
-
log.info('Hello World!');
|
|
42
|
-
log.warn(`The ${'sun'.yellow} is shining!`);
|
|
43
|
-
logStub.output.should.equals([
|
|
44
|
-
'info: Hello World!',
|
|
45
|
-
`warn: The ${'sun'.yellow} is shining!`
|
|
46
|
-
].join('\n'));
|
|
47
|
-
});
|
|
48
|
-
it('stubbing log stripping colors', () => {
|
|
49
|
-
let logStub = stubLog(sandbox, log, {stripColors: true});
|
|
50
|
-
log.info('Hello World!');
|
|
51
|
-
log.warn(`The ${'sun'.yellow} is shining!`);
|
|
52
|
-
logStub.output.should.equals([
|
|
53
|
-
'info: Hello World!',
|
|
54
|
-
'warn: The sun is shining!'
|
|
55
|
-
].join('\n'));
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
16
|
### withSandbox
|
|
61
17
|
|
|
62
18
|
Use when mixing up `sinon` APIs (mocks, spies, stubs).
|
|
@@ -100,51 +56,6 @@ describe('withMocks', withMocks({api}, (mocks) => {
|
|
|
100
56
|
}));
|
|
101
57
|
```
|
|
102
58
|
|
|
103
|
-
### fakeTime
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
import { fakeTime } from '@appium/test-support';
|
|
107
|
-
|
|
108
|
-
function doSomething() {
|
|
109
|
-
return new B.Promise((resolve) => {
|
|
110
|
-
let ret = '';
|
|
111
|
-
function appendOneByOne () {
|
|
112
|
-
if(ret.length >= 10) {
|
|
113
|
-
return resolve(ret);
|
|
114
|
-
}
|
|
115
|
-
setTimeout(() => {
|
|
116
|
-
ret = ret + ret.length;
|
|
117
|
-
appendOneByOne();
|
|
118
|
-
}, 1000);
|
|
119
|
-
}
|
|
120
|
-
appendOneByOne();
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
describe('fakeTime', () => {
|
|
125
|
-
let sandbox;
|
|
126
|
-
// create sandbox ...
|
|
127
|
-
|
|
128
|
-
it('should fake time', async () => {
|
|
129
|
-
let timeLord = fakeTime(sandbox);
|
|
130
|
-
let p = doSomething();
|
|
131
|
-
timeLord.speedup(200, 60); // interval=200, times=60
|
|
132
|
-
(await p).should.equals('0123456789');
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Travis Android Emu Setup
|
|
138
|
-
|
|
139
|
-
On [Travis](https://travis-ci.org/), setting up an emulator takes a lot of boilerplate.
|
|
140
|
-
While the configuration needs to be done on a case-by-case basis, the actual startup
|
|
141
|
-
can be scripted. Toward that, there are two scripts:
|
|
142
|
-
* `android-emu-travis-pre` - creates a device (configured with the environment variables
|
|
143
|
-
`ANDROID_EMU_NAME`, `ANDROID_EMU_TARGET`, and `ANDROID_EMU_ABI`) and starts it
|
|
144
|
-
in the background
|
|
145
|
-
* `android-emu-travis-post` - waits for the device to be booted, and then goes
|
|
146
|
-
to its home screen
|
|
147
|
-
|
|
148
59
|
## License
|
|
149
60
|
|
|
150
61
|
Apache-2.0
|
package/build/lib/index.d.ts
CHANGED
package/build/lib/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifySandbox = exports.withSandbox = exports.verifyMocks = exports.withMocks =
|
|
3
|
+
exports.verifySandbox = exports.withSandbox = exports.verifyMocks = exports.withMocks = void 0;
|
|
4
4
|
// this just needs to be imported, for the functionality to be injected
|
|
5
5
|
require("./unhandled-rejection");
|
|
6
|
-
var env_utils_1 = require("./env-utils");
|
|
7
|
-
Object.defineProperty(exports, "stubEnv", { enumerable: true, get: function () { return env_utils_1.stubEnv; } });
|
|
8
|
-
var log_utils_1 = require("./log-utils");
|
|
9
|
-
Object.defineProperty(exports, "stubLog", { enumerable: true, get: function () { return log_utils_1.stubLog; } });
|
|
10
6
|
var mock_utils_1 = require("./mock-utils");
|
|
11
7
|
Object.defineProperty(exports, "withMocks", { enumerable: true, get: function () { return mock_utils_1.withMocks; } });
|
|
12
8
|
Object.defineProperty(exports, "verifyMocks", { enumerable: true, get: function () { return mock_utils_1.verifyMocks; } });
|
package/build/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;AAAA,uEAAuE;AACvE,iCAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;AAAA,uEAAuE;AACvE,iCAA+B;AAE/B,2CAAoD;AAA5C,uGAAA,SAAS,OAAA;AAAE,yGAAA,WAAW,OAAA;AAC9B,iDAA2D;AAAnD,4GAAA,WAAW,OAAA;AAAE,8GAAA,aAAa,OAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// this just needs to be imported, for the functionality to be injected
|
|
2
2
|
import './unhandled-rejection';
|
|
3
3
|
|
|
4
|
-
export {stubEnv} from './env-utils';
|
|
5
|
-
export {stubLog} from './log-utils';
|
|
6
4
|
export {withMocks, verifyMocks} from './mock-utils';
|
|
7
5
|
export {withSandbox, verifySandbox} from './sandbox-utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/test-support",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A collection of test utilities used across Appium packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@appium/support": "^
|
|
48
|
+
"@appium/support": "^6.0.0",
|
|
49
49
|
"@colors/colors": "1.6.0",
|
|
50
50
|
"bluebird": "3.7.2",
|
|
51
51
|
"lodash": "4.17.21",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1d16ac6b4521b1ac06b8650c6bb5c311d8d49ae3"
|
|
64
64
|
}
|
package/build/lib/env-utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-utils.d.ts","sourceRoot":"","sources":["../../lib/env-utils.js"],"names":[],"mappings":"AAAA;;GAEG;AACH,gCAUC"}
|
package/build/lib/env-utils.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stubEnv = stubEnv;
|
|
4
|
-
/**
|
|
5
|
-
* Creates Mocha "before each" and "after each" hooks to restore `process.env` after every test.
|
|
6
|
-
*/
|
|
7
|
-
function stubEnv() {
|
|
8
|
-
/** @type {NodeJS.ProcessEnv} */
|
|
9
|
-
let envBackup;
|
|
10
|
-
beforeEach(function beforeEach() {
|
|
11
|
-
envBackup = process.env;
|
|
12
|
-
process.env = { ...process.env };
|
|
13
|
-
});
|
|
14
|
-
afterEach(function afterEach() {
|
|
15
|
-
process.env = envBackup;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=env-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"env-utils.js","sourceRoot":"","sources":["../../lib/env-utils.js"],"names":[],"mappings":";;AAeQ,0BAAO;AAff;;GAEG;AACH,SAAS,OAAO;IACd,gCAAgC;IAChC,IAAI,SAAS,CAAC;IACd,UAAU,CAAC,SAAS,UAAU;QAC5B,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;QACxB,OAAO,CAAC,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC,GAAG,EAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,SAAS,SAAS;QAC1B,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/build/lib/log-utils.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for {@linkcode LogStub} constructor
|
|
3
|
-
*/
|
|
4
|
-
export type LogStubOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* - If `true`, strip ANSI colors from output
|
|
7
|
-
*/
|
|
8
|
-
stripColors?: boolean | undefined;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Instantiates a {@linkcode LogStub} object
|
|
12
|
-
* @param {import('sinon').SinonSandbox} sandbox
|
|
13
|
-
* @param {import('@appium/types').AppiumLogger} log
|
|
14
|
-
* @param {LogStubOptions} [opts]
|
|
15
|
-
* @returns {LogStub}
|
|
16
|
-
*/
|
|
17
|
-
export function stubLog(sandbox: import("sinon").SinonSandbox, log: import("@appium/types").AppiumLogger, opts?: LogStubOptions): LogStub;
|
|
18
|
-
declare class LogStub {
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {LogStubOptions} [opts]
|
|
22
|
-
*/
|
|
23
|
-
constructor(opts?: LogStubOptions);
|
|
24
|
-
output: string;
|
|
25
|
-
stripColors: boolean;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {string} level
|
|
29
|
-
* @param {any} message
|
|
30
|
-
*/
|
|
31
|
-
log(level: string, message: any): void;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=log-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-utils.d.ts","sourceRoot":"","sources":["../../lib/log-utils.js"],"names":[],"mappings":";;;;;;;;;AA2BA;;;;;;GAMG;AACH,iCALW,OAAO,OAAO,EAAE,YAAY,OAC5B,OAAO,eAAe,EAAE,YAAY,SACpC,cAAc,GACZ,OAAO,CAUnB;AAxCD;IACE;;;OAGG;IACH,mBAFW,cAAc,EAKxB;IAFC,eAAgB;IAChB,qBAA4C;IAE9C;;;;OAIG;IACH,WAHW,MAAM,WACN,GAAG,QAUb;CACF"}
|
package/build/lib/log-utils.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stubLog = stubLog;
|
|
4
|
-
require("@colors/colors");
|
|
5
|
-
class LogStub {
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {LogStubOptions} [opts]
|
|
9
|
-
*/
|
|
10
|
-
constructor(opts = {}) {
|
|
11
|
-
this.output = '';
|
|
12
|
-
this.stripColors = Boolean(opts.stripColors);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {string} level
|
|
17
|
-
* @param {any} message
|
|
18
|
-
*/
|
|
19
|
-
log(level, message) {
|
|
20
|
-
if (this.stripColors) {
|
|
21
|
-
message = message.stripColors;
|
|
22
|
-
}
|
|
23
|
-
if (this.output.length > 0) {
|
|
24
|
-
this.output += '\n';
|
|
25
|
-
}
|
|
26
|
-
this.output = `${this.output}${level}: ${message}`;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Instantiates a {@linkcode LogStub} object
|
|
31
|
-
* @param {import('sinon').SinonSandbox} sandbox
|
|
32
|
-
* @param {import('@appium/types').AppiumLogger} log
|
|
33
|
-
* @param {LogStubOptions} [opts]
|
|
34
|
-
* @returns {LogStub}
|
|
35
|
-
*/
|
|
36
|
-
function stubLog(sandbox, log, opts = {}) {
|
|
37
|
-
let logStub = new LogStub(opts);
|
|
38
|
-
for (let l of log.levels) {
|
|
39
|
-
sandbox.stub(log, l).callsFake(function doLogging(mess) {
|
|
40
|
-
logStub.log(l, mess);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return logStub;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Options for {@linkcode LogStub} constructor
|
|
47
|
-
* @typedef LogStubOptions
|
|
48
|
-
* @property {boolean} [stripColors] - If `true`, strip ANSI colors from output
|
|
49
|
-
*/
|
|
50
|
-
//# sourceMappingURL=log-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-utils.js","sourceRoot":"","sources":["../../lib/log-utils.js"],"names":[],"mappings":";;AA4CQ,0BAAO;AA5Cf,0BAAwB;AAExB,MAAM,OAAO;IACX;;;OAGG;IACH,YAAY,IAAI,GAAG,EAAE;QACnB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IACD;;;;OAIG;IACH,GAAG,CAAC,KAAK,EAAE,OAAO;QAChB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;QAChC,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;IACrD,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE;IACtC,IAAI,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,SAAS,CAAC,IAAI;YACpD,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAID;;;;GAIG"}
|
package/lib/env-utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates Mocha "before each" and "after each" hooks to restore `process.env` after every test.
|
|
3
|
-
*/
|
|
4
|
-
function stubEnv() {
|
|
5
|
-
/** @type {NodeJS.ProcessEnv} */
|
|
6
|
-
let envBackup;
|
|
7
|
-
beforeEach(function beforeEach() {
|
|
8
|
-
envBackup = process.env;
|
|
9
|
-
process.env = {...process.env};
|
|
10
|
-
});
|
|
11
|
-
afterEach(function afterEach() {
|
|
12
|
-
process.env = envBackup;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {stubEnv};
|
package/lib/log-utils.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import '@colors/colors';
|
|
2
|
-
|
|
3
|
-
class LogStub {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {LogStubOptions} [opts]
|
|
7
|
-
*/
|
|
8
|
-
constructor(opts = {}) {
|
|
9
|
-
this.output = '';
|
|
10
|
-
this.stripColors = Boolean(opts.stripColors);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param {string} level
|
|
15
|
-
* @param {any} message
|
|
16
|
-
*/
|
|
17
|
-
log(level, message) {
|
|
18
|
-
if (this.stripColors) {
|
|
19
|
-
message = message.stripColors;
|
|
20
|
-
}
|
|
21
|
-
if (this.output.length > 0) {
|
|
22
|
-
this.output += '\n';
|
|
23
|
-
}
|
|
24
|
-
this.output = `${this.output}${level}: ${message}`;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Instantiates a {@linkcode LogStub} object
|
|
30
|
-
* @param {import('sinon').SinonSandbox} sandbox
|
|
31
|
-
* @param {import('@appium/types').AppiumLogger} log
|
|
32
|
-
* @param {LogStubOptions} [opts]
|
|
33
|
-
* @returns {LogStub}
|
|
34
|
-
*/
|
|
35
|
-
function stubLog(sandbox, log, opts = {}) {
|
|
36
|
-
let logStub = new LogStub(opts);
|
|
37
|
-
for (let l of log.levels) {
|
|
38
|
-
sandbox.stub(log, l).callsFake(function doLogging(mess) {
|
|
39
|
-
logStub.log(l, mess);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return logStub;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {stubLog};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Options for {@linkcode LogStub} constructor
|
|
49
|
-
* @typedef LogStubOptions
|
|
50
|
-
* @property {boolean} [stripColors] - If `true`, strip ANSI colors from output
|
|
51
|
-
*/
|