browserstack-cypress-cli 1.8.1 → 1.11.1
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/bin/commands/generateDownloads.js +39 -0
- package/bin/commands/generateReport.js +5 -4
- package/bin/commands/info.js +4 -3
- package/bin/commands/init.js +6 -6
- package/bin/commands/runs.js +227 -64
- package/bin/commands/stop.js +5 -65
- package/bin/helpers/archiver.js +5 -20
- package/bin/helpers/buildArtifacts.js +250 -0
- package/bin/helpers/capabilityHelper.js +15 -22
- package/bin/helpers/checkUploaded.js +153 -0
- package/bin/helpers/config.js +3 -0
- package/bin/helpers/constants.js +109 -13
- package/bin/helpers/fileHelpers.js +14 -0
- package/bin/helpers/hashUtil.js +70 -0
- package/bin/helpers/packageInstaller.js +134 -0
- package/bin/helpers/reporterHTML.js +169 -11
- package/bin/helpers/sync/syncSpecsLogs.js +37 -9
- package/bin/helpers/timeComponents.js +71 -0
- package/bin/helpers/usageReporting.js +35 -6
- package/bin/helpers/utils.js +420 -12
- package/bin/helpers/zipUpload.js +106 -27
- package/bin/runner.js +119 -118
- package/package.json +4 -1
- package/test/test_files/dummy_bstack.json +0 -0
- package/test/test_files/dummy_bstack_2.json +0 -1
- package/test/test_files/dummy_bstack_3.json +0 -3
- package/test/unit/bin/commands/generateReport.js +0 -112
- package/test/unit/bin/commands/info.js +0 -374
- package/test/unit/bin/commands/init.js +0 -187
- package/test/unit/bin/commands/runs.js +0 -700
- package/test/unit/bin/commands/stop.js +0 -388
- package/test/unit/bin/helpers/archiver.js +0 -57
- package/test/unit/bin/helpers/build.js +0 -210
- package/test/unit/bin/helpers/capabilityHelper.js +0 -1049
- package/test/unit/bin/helpers/fileHelpers.js +0 -102
- package/test/unit/bin/helpers/reporterHTML.js +0 -272
- package/test/unit/bin/helpers/sync/failedSpecDetails.js +0 -76
- package/test/unit/bin/helpers/sync/specSummary.js +0 -55
- package/test/unit/bin/helpers/sync/syncSpecsLogs.js +0 -403
- package/test/unit/bin/helpers/usageReporting.js +0 -411
- package/test/unit/bin/helpers/utils.js +0 -1770
- package/test/unit/bin/helpers/zipUpload.js +0 -205
- package/test/unit/support/fixtures/testObjects.js +0 -149
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
const cp = require("child_process"),
|
|
2
|
-
fs = require("fs");
|
|
3
|
-
|
|
4
|
-
const chai = require("chai"),
|
|
5
|
-
expect = chai.expect,
|
|
6
|
-
assert = chai.assert,
|
|
7
|
-
sinon = require("sinon"),
|
|
8
|
-
chaiAsPromised = require("chai-as-promised"),
|
|
9
|
-
rewire = require("rewire");
|
|
10
|
-
|
|
11
|
-
const logger = require("../../../../bin/helpers/logger").winstonLogger,
|
|
12
|
-
testObjects = require("../../support/fixtures/testObjects");
|
|
13
|
-
|
|
14
|
-
const usageReporting = rewire("../../../../bin/helpers/usageReporting");
|
|
15
|
-
|
|
16
|
-
chai.use(chaiAsPromised);
|
|
17
|
-
logger.transports["console.info"].silent = true;
|
|
18
|
-
|
|
19
|
-
_os = usageReporting.__get__("_os");
|
|
20
|
-
os_version = usageReporting.__get__("os_version");
|
|
21
|
-
isUsageReportingEnabled = usageReporting.__get__("isUsageReportingEnabled");
|
|
22
|
-
npm_version = usageReporting.__get__("npm_version");
|
|
23
|
-
get_version = usageReporting.__get__("get_version");
|
|
24
|
-
ci_environment = usageReporting.__get__("ci_environment");
|
|
25
|
-
local_cypress_version = usageReporting.__get__("local_cypress_version");
|
|
26
|
-
bstack_json_found_in_pwd = usageReporting.__get__("bstack_json_found_in_pwd");
|
|
27
|
-
cypress_json_found_in_pwd = usageReporting.__get__("cypress_json_found_in_pwd");
|
|
28
|
-
npm_global_path = usageReporting.__get__("npm_global_path");
|
|
29
|
-
cli_version_and_path = usageReporting.__get__("cli_version_and_path");
|
|
30
|
-
|
|
31
|
-
describe("usageReporting", () => {
|
|
32
|
-
describe("_os", () => {
|
|
33
|
-
it("should return string", () => {
|
|
34
|
-
assert.typeOf(_os(), "string");
|
|
35
|
-
});
|
|
36
|
-
it("should never be null", () => {
|
|
37
|
-
expect(_os()).to.not.be.null;
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe("os_version", () => {
|
|
42
|
-
it("should return string", () => {
|
|
43
|
-
assert.typeOf(os_version(), "string");
|
|
44
|
-
});
|
|
45
|
-
it("should never be null", () => {
|
|
46
|
-
expect(os_version()).to.not.be.null;
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe("npm_version", () => {
|
|
51
|
-
var sandbox;
|
|
52
|
-
|
|
53
|
-
before(() => {
|
|
54
|
-
sandbox = sinon.createSandbox();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
after(() => {
|
|
58
|
-
sandbox.restore();
|
|
59
|
-
sinon.restore();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should return string if found version", () => {
|
|
63
|
-
let execSyncStub = sandbox.stub(cp, "execSync").returns("random string");
|
|
64
|
-
|
|
65
|
-
let result = npm_version();
|
|
66
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
67
|
-
assert.typeOf(result, "string");
|
|
68
|
-
|
|
69
|
-
execSyncStub.restore();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should return null in case of error", () => {
|
|
73
|
-
let execSyncStub = sandbox.stub(cp, "execSync").yields(new Error("random error"));
|
|
74
|
-
|
|
75
|
-
let result = npm_version();
|
|
76
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
77
|
-
expect(result).to.be.null;
|
|
78
|
-
|
|
79
|
-
execSyncStub.restore();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("local_cypress_version", () => {
|
|
84
|
-
let bsConfig = testObjects.sampleBsConfig;
|
|
85
|
-
var sandbox;
|
|
86
|
-
|
|
87
|
-
before(() => {
|
|
88
|
-
sandbox = sinon.createSandbox();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
after(() => {
|
|
92
|
-
sandbox.restore();
|
|
93
|
-
sinon.restore();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("should return string if found version if bsConfig not defined", () => {
|
|
97
|
-
let execSyncStub = sandbox.stub(cp, "execSync").returns("random string");
|
|
98
|
-
|
|
99
|
-
let result = local_cypress_version(null);
|
|
100
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
101
|
-
assert.typeOf(result, "string");
|
|
102
|
-
|
|
103
|
-
execSyncStub.restore();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("should return null in case of error if bsConfig not defined", () => {
|
|
107
|
-
let execSyncStub = sandbox
|
|
108
|
-
.stub(cp, "execSync")
|
|
109
|
-
.yields(new Error("random error"));
|
|
110
|
-
|
|
111
|
-
let result = local_cypress_version(null);
|
|
112
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
113
|
-
expect(result).to.be.null;
|
|
114
|
-
|
|
115
|
-
execSyncStub.restore();
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("should return string if found version if bsConfig is defined", () => {
|
|
119
|
-
let execSyncStub = sandbox.stub(cp, "execSync").returns("random string");
|
|
120
|
-
|
|
121
|
-
let result = local_cypress_version(bsConfig);
|
|
122
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
123
|
-
assert.typeOf(result, "string");
|
|
124
|
-
|
|
125
|
-
execSyncStub.restore();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("should return null in case of error if bsConfig is defined", () => {
|
|
129
|
-
let execSyncStub = sandbox
|
|
130
|
-
.stub(cp, "execSync")
|
|
131
|
-
.yields(new Error("random error"));
|
|
132
|
-
|
|
133
|
-
let result = local_cypress_version(bsConfig);
|
|
134
|
-
sinon.assert.calledTwice(execSyncStub);
|
|
135
|
-
expect(result).to.be.null;
|
|
136
|
-
|
|
137
|
-
execSyncStub.restore();
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("bstack_json_found_in_pwd", () => {
|
|
142
|
-
var sandbox;
|
|
143
|
-
|
|
144
|
-
before(() => {
|
|
145
|
-
sandbox = sinon.createSandbox();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
after(() => {
|
|
149
|
-
sandbox.restore();
|
|
150
|
-
sinon.restore();
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("should return true file exists", () => {
|
|
154
|
-
let existsSyncStub = sandbox.stub(fs, "existsSync").returns(true);
|
|
155
|
-
|
|
156
|
-
let result = bstack_json_found_in_pwd();
|
|
157
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
158
|
-
assert.equal(result, true);
|
|
159
|
-
|
|
160
|
-
existsSyncStub.restore();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("should return false if file doesn not exist", () => {
|
|
164
|
-
let existsSyncStub = sandbox.stub(fs, "existsSync").returns(false);
|
|
165
|
-
|
|
166
|
-
let result = bstack_json_found_in_pwd();
|
|
167
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
168
|
-
assert.equal(result, false);
|
|
169
|
-
|
|
170
|
-
existsSyncStub.restore();
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it("should return null in case of error", () => {
|
|
174
|
-
let existsSyncStub = sandbox.stub(fs, "existsSync").yields(new Error("random error"));
|
|
175
|
-
|
|
176
|
-
let result = bstack_json_found_in_pwd();
|
|
177
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
178
|
-
expect(result).to.be.null;
|
|
179
|
-
|
|
180
|
-
existsSyncStub.restore();
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
describe("cypress_json_found_in_pwd", () => {
|
|
185
|
-
var sandbox;
|
|
186
|
-
|
|
187
|
-
before(() => {
|
|
188
|
-
sandbox = sinon.createSandbox();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
after(() => {
|
|
192
|
-
sandbox.restore();
|
|
193
|
-
sinon.restore();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("should return true file exists", () => {
|
|
197
|
-
let existsSyncStub = sandbox.stub(fs, "existsSync").returns(true);
|
|
198
|
-
|
|
199
|
-
let result = cypress_json_found_in_pwd();
|
|
200
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
201
|
-
assert.equal(result, true);
|
|
202
|
-
|
|
203
|
-
existsSyncStub.restore();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("should return false if file doesn not exist", () => {
|
|
207
|
-
let existsSyncStub = sandbox.stub(fs, "existsSync").returns(false);
|
|
208
|
-
|
|
209
|
-
let result = cypress_json_found_in_pwd();
|
|
210
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
211
|
-
assert.equal(result, false);
|
|
212
|
-
|
|
213
|
-
existsSyncStub.restore();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("should return null in case of error", () => {
|
|
217
|
-
let existsSyncStub = sandbox
|
|
218
|
-
.stub(fs, "existsSync")
|
|
219
|
-
.yields(new Error("random error"));
|
|
220
|
-
|
|
221
|
-
let result = cypress_json_found_in_pwd();
|
|
222
|
-
sinon.assert.calledOnce(existsSyncStub);
|
|
223
|
-
expect(result).to.be.null;
|
|
224
|
-
|
|
225
|
-
existsSyncStub.restore();
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe("npm_global_path", () => {
|
|
230
|
-
var sandbox;
|
|
231
|
-
|
|
232
|
-
before(() => {
|
|
233
|
-
sandbox = sinon.createSandbox();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
after(() => {
|
|
237
|
-
sandbox.restore();
|
|
238
|
-
sinon.restore();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("should return string", () => {
|
|
242
|
-
let execSyncStub = sandbox.stub(cp, "execSync").returns("random string");
|
|
243
|
-
|
|
244
|
-
let result = npm_global_path();
|
|
245
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
246
|
-
assert.typeOf(result, "string");
|
|
247
|
-
|
|
248
|
-
execSyncStub.restore();
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
describe("cli_version_and_path", () => {
|
|
253
|
-
let bsConfig = testObjects.sampleBsConfig;
|
|
254
|
-
var sandbox;
|
|
255
|
-
|
|
256
|
-
before(() => {
|
|
257
|
-
sandbox = sinon.createSandbox();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
after(() => {
|
|
261
|
-
sandbox.restore();
|
|
262
|
-
sinon.restore();
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it("should return object if cli path and version found in local project and bsConfig is defined", () => {
|
|
266
|
-
let execSyncStub = sandbox.stub(cp, "execSync").returns("random string");
|
|
267
|
-
|
|
268
|
-
let result = cli_version_and_path(bsConfig);
|
|
269
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
270
|
-
assert.typeOf(result, "object");
|
|
271
|
-
expect(result).to.have.property("version").that.is.not.null;
|
|
272
|
-
expect(result).to.have.property("path").that.is.not.null;
|
|
273
|
-
|
|
274
|
-
execSyncStub.restore();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("should return object if cli path and version found globally and bsConfig is defined", () => {
|
|
278
|
-
let execSyncStub = sandbox.stub(cp, "execSync");
|
|
279
|
-
execSyncStub.onCall(0).yields(new Error("random error"));
|
|
280
|
-
execSyncStub.onCall(1).returns("random string");
|
|
281
|
-
execSyncStub.onCall(2).returns("random string 2");
|
|
282
|
-
|
|
283
|
-
let result = cli_version_and_path(bsConfig);
|
|
284
|
-
sinon.assert.calledThrice(execSyncStub);
|
|
285
|
-
assert.typeOf(result, "object");
|
|
286
|
-
expect(result).to.have.property("version").that.is.not.null;
|
|
287
|
-
expect(result).to.have.property("path").that.is.not.null;
|
|
288
|
-
|
|
289
|
-
execSyncStub.restore();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("should return object if cli path and version not found locally as well as globally and bsConfig is defined", () => {
|
|
293
|
-
let execSyncStub = sandbox.stub(cp, "execSync");
|
|
294
|
-
execSyncStub.onCall(0).yields(new Error("random error"));
|
|
295
|
-
execSyncStub.onCall(1).yields(new Error("random error 2"));
|
|
296
|
-
|
|
297
|
-
let result = cli_version_and_path(bsConfig);
|
|
298
|
-
sinon.assert.calledTwice(execSyncStub);
|
|
299
|
-
assert.typeOf(result, "object");
|
|
300
|
-
expect(result).to.have.property("version").that.is.null;
|
|
301
|
-
expect(result).to.have.property("path").that.is.null;
|
|
302
|
-
|
|
303
|
-
execSyncStub.restore();
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it("should return object if cli path and version found globally and bsConfig is not defined", () => {
|
|
307
|
-
let execSyncStub = sandbox.stub(cp, "execSync").yields(new Error("random error"));
|
|
308
|
-
|
|
309
|
-
let result = cli_version_and_path(null);
|
|
310
|
-
sinon.assert.calledOnce(execSyncStub);
|
|
311
|
-
assert.typeOf(result, "object");
|
|
312
|
-
expect(result).to.have.property("version").that.is.null;
|
|
313
|
-
expect(result).to.have.property("path").that.is.null;
|
|
314
|
-
|
|
315
|
-
execSyncStub.restore();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it("should return object if cli path and version not found globally and bsConfig is not defined", () => {
|
|
319
|
-
let execSyncStub = sandbox.stub(cp, "execSync");
|
|
320
|
-
execSyncStub.onCall(0).returns("random string");
|
|
321
|
-
execSyncStub.onCall(1).returns("random string 2");
|
|
322
|
-
|
|
323
|
-
let result = cli_version_and_path(null);
|
|
324
|
-
sinon.assert.calledTwice(execSyncStub);
|
|
325
|
-
assert.typeOf(result, "object");
|
|
326
|
-
expect(result).to.have.property("version").that.is.not.null;
|
|
327
|
-
expect(result).to.have.property("path").that.is.not.null;
|
|
328
|
-
|
|
329
|
-
execSyncStub.restore();
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
describe("isUsageReportingEnabled", () => {
|
|
334
|
-
it("should return string if env var is set", () => {
|
|
335
|
-
process.env.DISABLE_USAGE_REPORTING = true;
|
|
336
|
-
assert.typeOf(isUsageReportingEnabled(), "string");
|
|
337
|
-
delete process.env.DISABLE_USAGE_REPORTING;
|
|
338
|
-
});
|
|
339
|
-
it("should return undefined if env var is not set", () => {
|
|
340
|
-
expect(isUsageReportingEnabled()).to.be.undefined;
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
describe("ci_environment", () => {
|
|
345
|
-
afterEach(() => {
|
|
346
|
-
delete process.env.JENKINS_URL;
|
|
347
|
-
delete process.env.CI;
|
|
348
|
-
delete process.env.CIRCLECI;
|
|
349
|
-
delete process.env.TRAVIS;
|
|
350
|
-
delete process.env.CI_NAME;
|
|
351
|
-
delete process.env.BITBUCKET_BRANCH;
|
|
352
|
-
delete process.env.BITBUCKET_COMMIT;
|
|
353
|
-
delete process.env.DRONE;
|
|
354
|
-
delete process.env.SEMAPHORE;
|
|
355
|
-
delete process.env.GITLAB_CI;
|
|
356
|
-
delete process.env.BUILDKITE;
|
|
357
|
-
delete process.env.TF_BUILD;
|
|
358
|
-
});
|
|
359
|
-
it("handle jenkins", () => {
|
|
360
|
-
process.env.JENKINS_URL = "sample jenkins url";
|
|
361
|
-
expect(ci_environment()).to.equal("Jenkins");
|
|
362
|
-
});
|
|
363
|
-
it("handle CircleCI", () => {
|
|
364
|
-
process.env.CI = true;
|
|
365
|
-
process.env.CIRCLECI = true;
|
|
366
|
-
expect(ci_environment()).to.equal("CircleCI");
|
|
367
|
-
});
|
|
368
|
-
it("handle Travis CI", () => {
|
|
369
|
-
process.env.CI = true;
|
|
370
|
-
process.env.TRAVIS = true;
|
|
371
|
-
expect(ci_environment()).to.equal("Travis CI");
|
|
372
|
-
});
|
|
373
|
-
it("handle Codeship", () => {
|
|
374
|
-
process.env.CI = true;
|
|
375
|
-
process.env.CI_NAME = "codeship";
|
|
376
|
-
expect(ci_environment()).to.equal("Codeship");
|
|
377
|
-
});
|
|
378
|
-
it("handle Bitbucket", () => {
|
|
379
|
-
process.env.BITBUCKET_BRANCH = true;
|
|
380
|
-
process.env.BITBUCKET_COMMIT = true;
|
|
381
|
-
expect(ci_environment()).to.equal("Bitbucket");
|
|
382
|
-
});
|
|
383
|
-
it("handle Drone", () => {
|
|
384
|
-
process.env.CI = true;
|
|
385
|
-
process.env.DRONE = true;
|
|
386
|
-
expect(ci_environment()).to.equal("Drone");
|
|
387
|
-
});
|
|
388
|
-
it("handle Semaphore", () => {
|
|
389
|
-
process.env.CI = true;
|
|
390
|
-
process.env.SEMAPHORE = true;
|
|
391
|
-
expect(ci_environment()).to.equal("Semaphore");
|
|
392
|
-
});
|
|
393
|
-
it("handle GitLab", () => {
|
|
394
|
-
process.env.CI = true;
|
|
395
|
-
process.env.GITLAB_CI = true;
|
|
396
|
-
expect(ci_environment()).to.equal("GitLab");
|
|
397
|
-
});
|
|
398
|
-
it("handle Buildkite", () => {
|
|
399
|
-
process.env.CI = true;
|
|
400
|
-
process.env.BUILDKITE = true;
|
|
401
|
-
expect(ci_environment()).to.equal("Buildkite");
|
|
402
|
-
});
|
|
403
|
-
it("handle Visual Studio Team Services", () => {
|
|
404
|
-
process.env.TF_BUILD = "True";
|
|
405
|
-
expect(ci_environment()).to.equal("Visual Studio Team Services");
|
|
406
|
-
});
|
|
407
|
-
it("return null in case of no ENV var is set", () => {
|
|
408
|
-
expect(ci_environment()).to.be.null;
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
});
|