browserstack-cypress-cli 1.8.0 → 1.11.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.
Files changed (47) hide show
  1. package/.nyc_output/4a952689-f098-4108-8a3e-26deb80519a8.json +1 -0
  2. package/.nyc_output/97ba506f-6310-4b5c-b0cf-54cdd82c7af6.json +1 -0
  3. package/.nyc_output/processinfo/4a952689-f098-4108-8a3e-26deb80519a8.json +1 -0
  4. package/.nyc_output/processinfo/97ba506f-6310-4b5c-b0cf-54cdd82c7af6.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -0
  6. package/bin/commands/generateDownloads.js +39 -0
  7. package/bin/commands/generateReport.js +1 -0
  8. package/bin/commands/info.js +1 -0
  9. package/bin/commands/runs.js +186 -60
  10. package/bin/commands/stop.js +3 -63
  11. package/bin/helpers/archiver.js +5 -20
  12. package/bin/helpers/buildArtifacts.js +220 -0
  13. package/bin/helpers/capabilityHelper.js +15 -22
  14. package/bin/helpers/checkUploaded.js +153 -0
  15. package/bin/helpers/config.js +3 -0
  16. package/bin/helpers/constants.js +98 -13
  17. package/bin/helpers/fileHelpers.js +14 -0
  18. package/bin/helpers/hashUtil.js +70 -0
  19. package/bin/helpers/packageInstaller.js +138 -0
  20. package/bin/helpers/reporterHTML.js +117 -9
  21. package/bin/helpers/sync/syncSpecsLogs.js +36 -8
  22. package/bin/helpers/timeComponents.js +71 -0
  23. package/bin/helpers/usageReporting.js +5 -4
  24. package/bin/helpers/utils.js +388 -9
  25. package/bin/helpers/zipUpload.js +42 -24
  26. package/bin/runner.js +108 -113
  27. package/package.json +6 -2
  28. package/test/test_files/dummy_bstack.json +0 -0
  29. package/test/test_files/dummy_bstack_2.json +0 -1
  30. package/test/test_files/dummy_bstack_3.json +0 -3
  31. package/test/unit/bin/commands/generateReport.js +0 -112
  32. package/test/unit/bin/commands/info.js +0 -374
  33. package/test/unit/bin/commands/init.js +0 -187
  34. package/test/unit/bin/commands/runs.js +0 -700
  35. package/test/unit/bin/commands/stop.js +0 -388
  36. package/test/unit/bin/helpers/archiver.js +0 -57
  37. package/test/unit/bin/helpers/build.js +0 -210
  38. package/test/unit/bin/helpers/capabilityHelper.js +0 -1049
  39. package/test/unit/bin/helpers/fileHelpers.js +0 -102
  40. package/test/unit/bin/helpers/reporterHTML.js +0 -272
  41. package/test/unit/bin/helpers/sync/failedSpecDetails.js +0 -76
  42. package/test/unit/bin/helpers/sync/specSummary.js +0 -55
  43. package/test/unit/bin/helpers/sync/syncSpecsLogs.js +0 -403
  44. package/test/unit/bin/helpers/usageReporting.js +0 -411
  45. package/test/unit/bin/helpers/utils.js +0 -1743
  46. package/test/unit/bin/helpers/zipUpload.js +0 -205
  47. package/test/unit/support/fixtures/testObjects.js +0 -149
@@ -1,205 +0,0 @@
1
- const chai = require("chai"),
2
- chaiAsPromised = require("chai-as-promised"),
3
- sinon = require("sinon"),
4
- request = require("request"),
5
- fs = require("fs");
6
-
7
- const Constants = require("../../../../bin/helpers/constants"),
8
- logger = require("../../../../bin/helpers/logger").winstonLogger,
9
- testObjects = require("../../support/fixtures/testObjects");
10
-
11
- const proxyquire = require("proxyquire").noCallThru();
12
-
13
- chai.use(chaiAsPromised);
14
- logger.transports["console.info"].silent = true;
15
-
16
- describe("zipUpload", () => {
17
- let bsConfig = testObjects.sampleBsConfig;
18
-
19
- var sandbox;
20
-
21
- beforeEach(() => {
22
- sandbox = sinon.createSandbox();
23
- getUserAgentStub = sandbox.stub().returns("random user-agent");
24
- createReadStreamStub = sandbox.stub(fs, "createReadStream");
25
- deleteZipStub = sandbox.stub().returns(true);
26
- });
27
-
28
- afterEach(() => {
29
- sandbox.restore();
30
- sinon.restore();
31
- });
32
-
33
- it("reject with error", () => {
34
- let requestStub = sandbox
35
- .stub(request, "post")
36
- .yields(new Error("random error"), null, null);
37
-
38
- const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
39
- "./utils": {
40
- getUserAgent: getUserAgentStub,
41
- },
42
- request: { post: requestStub },
43
- });
44
-
45
- return zipUploader
46
- .zipUpload(bsConfig, "./random_file_path")
47
- .then(function (data) {
48
- chai.assert.fail("Promise error");
49
- })
50
- .catch((error) => {
51
- sinon.assert.calledOnce(requestStub);
52
- sinon.assert.calledOnce(getUserAgentStub);
53
- sinon.assert.calledOnce(createReadStreamStub);
54
- chai.assert.equal(error.message, "random error");
55
- });
56
- });
57
-
58
- it("reject with error (if error present in response) if statusCode == 401", () => {
59
- let error = "non 200 code";
60
-
61
- let requestStub = sandbox
62
- .stub(request, "post")
63
- .yields(null, { statusCode: 401 }, JSON.stringify({ error: error }));
64
-
65
- const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
66
- "./utils": {
67
- getUserAgent: getUserAgentStub,
68
- },
69
- request: { post: requestStub },
70
- });
71
-
72
- return zipUploader
73
- .zipUpload(bsConfig, "./random_file_path")
74
- .then(function (data) {
75
- chai.assert.fail("Promise error");
76
- })
77
- .catch((error) => {
78
- sinon.assert.calledOnce(requestStub);
79
- sinon.assert.calledOnce(getUserAgentStub);
80
- sinon.assert.calledOnce(createReadStreamStub);
81
- chai.assert.equal(error, "non 200 code");
82
- });
83
- });
84
-
85
- it("reject with message if statusCode == 401 and error not in response", () => {
86
- let requestStub = sandbox
87
- .stub(request, "post")
88
- .yields(
89
- null,
90
- { statusCode: 401 },
91
- JSON.stringify({ message: "random message" })
92
- );
93
-
94
- const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
95
- "./utils": {
96
- getUserAgent: getUserAgentStub,
97
- },
98
- request: { post: requestStub },
99
- });
100
-
101
- return zipUploader
102
- .zipUpload(bsConfig, "./random_file_path")
103
- .then(function (data) {
104
- chai.assert.fail("Promise error");
105
- })
106
- .catch((error) => {
107
- sinon.assert.calledOnce(requestStub);
108
- sinon.assert.calledOnce(getUserAgentStub);
109
- sinon.assert.calledOnce(createReadStreamStub);
110
- chai.assert.equal(
111
- error,
112
- Constants.validationMessages.INVALID_DEFAULT_AUTH_PARAMS
113
- );
114
- });
115
- });
116
-
117
- it("reject with error (if error present in response) if statusCode != 200 and statusCode != 401", () => {
118
- let error = "non 200 and non 401 code";
119
-
120
- let requestStub = sandbox
121
- .stub(request, "post")
122
- .yields(null, { statusCode: 404 }, JSON.stringify({ error: error }));
123
-
124
- const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
125
- "./utils": {
126
- getUserAgent: getUserAgentStub,
127
- },
128
- request: { post: requestStub },
129
- });
130
-
131
- return zipUploader
132
- .zipUpload(bsConfig, "./random_file_path")
133
- .then(function (data) {
134
- chai.assert.fail("Promise error");
135
- })
136
- .catch((error) => {
137
- sinon.assert.calledOnce(requestStub);
138
- sinon.assert.calledOnce(getUserAgentStub);
139
- sinon.assert.calledOnce(createReadStreamStub);
140
- chai.assert.equal(error, "non 200 and non 401 code");
141
- });
142
- });
143
-
144
- it("reject with message if statusCode != 200 and statusCode != 401 and error not in response", () => {
145
- let requestStub = sandbox
146
- .stub(request, "post")
147
- .yields(
148
- null,
149
- { statusCode: 404 },
150
- JSON.stringify({ message: "random message" })
151
- );
152
-
153
- const zipUploader = proxyquire("../../../../bin/helpers/zipUpload", {
154
- "./utils": {
155
- getUserAgent: getUserAgentStub,
156
- },
157
- request: { post: requestStub },
158
- });
159
-
160
- return zipUploader
161
- .zipUpload(bsConfig, "./random_file_path")
162
- .then(function (data) {
163
- chai.assert.fail("Promise error");
164
- })
165
- .catch((error) => {
166
- sinon.assert.calledOnce(requestStub);
167
- sinon.assert.calledOnce(getUserAgentStub);
168
- sinon.assert.calledOnce(createReadStreamStub);
169
- chai.assert.equal(
170
- error,
171
- Constants.userMessages.ZIP_UPLOADER_NOT_REACHABLE
172
- );
173
- });
174
- });
175
-
176
- it("resolve with message if statusCode = 200", () => {
177
- let zip_url = "uploaded zip url";
178
- let requestStub = sandbox
179
- .stub(request, "post")
180
- .yields(null, { statusCode: 200 }, JSON.stringify({ zip_url: zip_url }));
181
-
182
- const zipUploader = proxyquire('../../../../bin/helpers/zipUpload', {
183
- './utils': {
184
- getUserAgent: getUserAgentStub,
185
- },
186
- request: {post: requestStub},
187
- './fileHelpers': {
188
- deleteZip: deleteZipStub,
189
- },
190
- });
191
-
192
- return zipUploader
193
- .zipUpload(bsConfig, "./random_file_path")
194
- .then(function (data) {
195
- sinon.assert.calledOnce(requestStub);
196
- sinon.assert.calledOnce(getUserAgentStub);
197
- sinon.assert.calledOnce(createReadStreamStub);
198
- sinon.assert.calledOnce(deleteZipStub);
199
- chai.assert.equal(data.zip_url, zip_url);
200
- })
201
- .catch((error) => {
202
- chai.assert.isNotOk(error, "Promise error");
203
- });
204
- });
205
- });
@@ -1,149 +0,0 @@
1
- const sampleBsConfig = {
2
- auth: {
3
- username: "random-username",
4
- access_key: "random-access-key",
5
- },
6
- run_settings: {
7
- cypress_proj_dir: "random path",
8
- cypressConfigFilePath: "random path",
9
- cypressProjectDir: "random path"
10
- }
11
- };
12
-
13
- const sampleBsConfigWithParallels = {
14
- auth: {
15
- username: "random-username",
16
- access_key: "random-access-key",
17
- },
18
- run_settings: {
19
- cypress_proj_dir: "random path",
20
- cypressConfigFilePath: "random path",
21
- cypressProjectDir: "random path",
22
- parallels: 10,
23
- },
24
- };
25
-
26
- const initSampleArgs = {
27
- _: ["init"],
28
- p: false,
29
- path: false,
30
- "disable-usage-reporting": undefined,
31
- disableUsageReporting: undefined,
32
- $0: "browserstack-cypress",
33
- };
34
-
35
- const buildInfoSampleArgs = {
36
- _: ["build-info", "f3c94f7203792d03a75be3912d19354fe0961e53"],
37
- cf: "browserstack.json",
38
- "config-file": "browserstack.json",
39
- configFile: "browserstack.json",
40
- "disable-usage-reporting": undefined,
41
- disableUsageReporting: undefined,
42
- $0: "browserstack-cypress",
43
- };
44
-
45
- const generateReportInputArgs = {
46
- _: ["generate-report", "f3c94f7203792d03a75be3912d19354fe0961e53"],
47
- cf: "browserstack.json",
48
- "config-file": "browserstack.json",
49
- configFile: "browserstack.json",
50
- "disable-usage-reporting": undefined,
51
- disableUsageReporting: undefined,
52
- $0: "browserstack-cypress",
53
- };
54
-
55
- const buildInfoSampleBody = {
56
- build_id: "random_hashed_id",
57
- framework: "cypress",
58
- status: "done",
59
- input_capabilities: {
60
- devices: ["Windows 10-chrome69", "Windows 10-chrome66"],
61
- testSuite: "random_test_id",
62
- customBuildName: "cypress build",
63
- local: false,
64
- localIdentifier: null,
65
- callbackURL: null,
66
- projectNotifyURL: null,
67
- project: "test",
68
- },
69
- start_time: "2020-02-20 09:28:35 UTC",
70
- device_statuses: {
71
- success: {
72
- "Windows 10-chrome69": "Success",
73
- "Windows 10-chrome66": "Success",
74
- },
75
- error: {},
76
- },
77
- test_suite_details: {
78
- url: "bs://random_test_id",
79
- name: "tests.zip",
80
- size: 354,
81
- },
82
- duration: "33 seconds",
83
- devices: {
84
- "Windows 10-chrome69": {
85
- session_id: "random_session_id_1",
86
- status: "done",
87
- test_status: {
88
- failed: 0,
89
- success: 3,
90
- queued: 0,
91
- ignored: 0,
92
- },
93
- },
94
- "Windows 10-chrome66": {
95
- session_id: "random_session_id_1",
96
- status: "done",
97
- test_status: {
98
- failed: 0,
99
- success: 3,
100
- queued: 0,
101
- ignored: 0,
102
- },
103
- },
104
- },
105
- };
106
-
107
- const buildStopSampleArgs = {
108
- _: ["build-stop", "f3c94f7203792d03a75be3912d19354fe0961e53"],
109
- cf: "browserstack.json",
110
- "config-file": "browserstack.json",
111
- configFile: "browserstack.json",
112
- "disable-usage-reporting": undefined,
113
- disableUsageReporting: undefined,
114
- $0: "browserstack-cypress",
115
- };
116
-
117
- const buildStopSampleBody = {
118
- message: "stopped 1 sessions",
119
- stopped_session_count: 1,
120
- };
121
-
122
- const sampleCapsData = {
123
-
124
- }
125
-
126
- const runSampleArgs = {
127
- _: ["run"],
128
- cf: "browserstack.json",
129
- "config-file": "browserstack.json",
130
- configFile: "browserstack.json",
131
- "disable-usage-reporting": undefined,
132
- p: undefined,
133
- "parallels": undefined,
134
- disableUsageReporting: undefined,
135
- $0: "browserstack-cypress",
136
- };
137
-
138
- module.exports = Object.freeze({
139
- sampleBsConfig,
140
- sampleBsConfigWithParallels,
141
- initSampleArgs,
142
- buildInfoSampleArgs,
143
- buildInfoSampleBody,
144
- buildStopSampleArgs,
145
- buildStopSampleBody,
146
- sampleCapsData,
147
- runSampleArgs,
148
- generateReportInputArgs,
149
- });