cypress 3.3.0 → 3.4.1

Sign up to get free protection for your applications and to get access to all the features.
package/lib/util.js CHANGED
@@ -9,6 +9,7 @@ function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defi
9
9
  var _ = require('lodash');
10
10
  var R = require('ramda');
11
11
  var os = require('os');
12
+ var crypto = require('crypto');
12
13
  var la = require('lazy-ass');
13
14
  var is = require('check-more-types');
14
15
  var tty = require('tty');
@@ -30,11 +31,44 @@ var _isInstalledGlobally = require('is-installed-globally');
30
31
  var pkg = require(path.join(__dirname, '..', 'package.json'));
31
32
  var logger = require('./logger');
32
33
  var debug = require('debug')('cypress:cli');
34
+ var fs = require('./fs');
33
35
 
34
36
  var issuesUrl = 'https://github.com/cypress-io/cypress/issues';
35
37
 
36
38
  var getosAsync = Promise.promisify(getos);
37
39
 
40
+ /**
41
+ * Returns SHA512 of a file
42
+ *
43
+ * Implementation lifted from https://github.com/sindresorhus/hasha
44
+ * but without bringing that dependency (since hasha is Node v8+)
45
+ */
46
+ var getFileChecksum = function getFileChecksum(filename) {
47
+ la(is.unemptyString(filename), 'expected filename', filename);
48
+
49
+ var hashStream = function hashStream() {
50
+ var s = crypto.createHash('sha512');
51
+
52
+ s.setEncoding('hex');
53
+
54
+ return s;
55
+ };
56
+
57
+ return new Promise(function (resolve, reject) {
58
+ var stream = fs.createReadStream(filename);
59
+
60
+ stream.on('error', reject).pipe(hashStream()).on('error', reject).on('finish', function () {
61
+ resolve(this.read());
62
+ });
63
+ });
64
+ };
65
+
66
+ var getFileSize = function getFileSize(filename) {
67
+ la(is.unemptyString(filename), 'expected filename', filename);
68
+
69
+ return fs.statAsync(filename).get('size');
70
+ };
71
+
38
72
  var isBrokenGtkDisplayRe = /Gtk: cannot open display/;
39
73
 
40
74
  var stringify = function stringify(val) {
@@ -49,7 +83,7 @@ function normalizeModuleOptions() {
49
83
 
50
84
  /**
51
85
  * Returns true if the platform is Linux. We do a lot of different
52
- * stuff on Linux (like XVFB) and it helps to has readable code
86
+ * stuff on Linux (like Xvfb) and it helps to has readable code
53
87
  */
54
88
  var isLinux = function isLinux() {
55
89
  return os.platform() === 'linux';
@@ -71,10 +105,11 @@ var isPossibleLinuxWithIncorrectDisplay = function isPossibleLinuxWithIncorrectD
71
105
  };
72
106
 
73
107
  var logBrokenGtkDisplayWarning = function logBrokenGtkDisplayWarning() {
74
- debug('Cypress exited due to a broken gtk display because of a potential invalid DISPLAY env... retrying after starting XVFB');
108
+ debug('Cypress exited due to a broken gtk display because of a potential invalid DISPLAY env... retrying after starting Xvfb');
75
109
 
76
110
  // if we get this error, we are on Linux and DISPLAY is set
77
111
  logger.warn(stripIndent(_templateObject, logSymbols.warning, process.env.DISPLAY));
112
+
78
113
  logger.warn();
79
114
  };
80
115
 
@@ -103,6 +138,27 @@ function printNodeOptions() {
103
138
  }
104
139
  }
105
140
 
141
+ /**
142
+ * Removes double quote characters
143
+ * from the start and end of the given string IF they are both present
144
+ *
145
+ * @example
146
+ ```
147
+ dequote('"foo"')
148
+ // returns string 'foo'
149
+ dequote('foo')
150
+ // returns string 'foo'
151
+ ```
152
+ */
153
+ var dequote = function dequote(str) {
154
+ la(is.string(str), 'expected a string to remove double quotes', str);
155
+ if (str.length > 1 && str[0] === '"' && str[str.length - 1] === '"') {
156
+ return str.substr(1, str.length - 2);
157
+ }
158
+
159
+ return str;
160
+ };
161
+
106
162
  var util = {
107
163
  normalizeModuleOptions: normalizeModuleOptions,
108
164
 
@@ -167,6 +223,10 @@ var util = {
167
223
 
168
224
  process.exit(1);
169
225
  },
226
+
227
+
228
+ dequote: dequote,
229
+
170
230
  titleize: function titleize() {
171
231
  for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
172
232
  args[_key] = arguments[_key];
@@ -184,7 +244,7 @@ var util = {
184
244
  calculateEta: function calculateEta(percent, elapsed) {
185
245
  // returns the number of seconds remaining
186
246
 
187
- // if we're at 100 already just return 0
247
+ // if we're at 100% already just return 0
188
248
  if (percent === 100) {
189
249
  return 0;
190
250
  }
@@ -194,6 +254,12 @@ var util = {
194
254
  // subtracting what's already elapsed
195
255
  return elapsed * (1 / (percent / 100)) - elapsed;
196
256
  },
257
+ convertPercentToPercentage: function convertPercentToPercentage(num) {
258
+ // convert a percent with values between 0 and 1
259
+ // with decimals, so that it is between 0 and 100
260
+ // and has no decimal places
261
+ return Math.round(_.isFinite(num) ? num * 100 : 0);
262
+ },
197
263
  secsRemaining: function secsRemaining(eta) {
198
264
  // calculate the seconds reminaing with no decimal places
199
265
  return (_.isFinite(eta) ? eta / 1000 : 0).toFixed(0);
@@ -244,30 +310,39 @@ var util = {
244
310
 
245
311
  return path.join(process.cwd(), '..', '..', filename);
246
312
  },
247
- getEnv: function getEnv(varName) {
313
+ getEnv: function getEnv(varName, trim) {
314
+ la(is.unemptyString(varName), 'expected environment variable name, not', varName);
315
+
248
316
  var envVar = process.env[varName];
249
317
  var configVar = process.env['npm_config_' + varName];
250
318
  var packageConfigVar = process.env['npm_package_config_' + varName];
251
319
 
320
+ var result = void 0;
321
+
252
322
  if (envVar) {
253
323
  debug('Using ' + varName + ' from environment variable');
254
324
 
255
- return envVar;
256
- }
257
-
258
- if (configVar) {
325
+ result = envVar;
326
+ } else if (configVar) {
259
327
  debug('Using ' + varName + ' from npm config');
260
328
 
261
- return configVar;
262
- }
263
-
264
- if (packageConfigVar) {
329
+ result = configVar;
330
+ } else if (packageConfigVar) {
265
331
  debug('Using ' + varName + ' from package.json config');
266
332
 
267
- return packageConfigVar;
333
+ result = packageConfigVar;
268
334
  }
269
335
 
270
- return undefined;
336
+ // environment variables are often set double quotes to escape characters
337
+ // and on Windows it can lead to weird things: for example
338
+ // set FOO="C:\foo.txt" && node -e "console.log('>>>%s<<<', process.env.FOO)"
339
+ // will print
340
+ // >>>"C:\foo.txt" <<<
341
+ // see https://github.com/cypress-io/cypress/issues/4506#issuecomment-506029942
342
+ // so for sanity sake we should first trim whitespace characters and remove
343
+ // double quotes around environment strings if the caller is expected to
344
+ // use this environment string as a file path
345
+ return trim ? dequote(_.trim(result)) : result;
271
346
  },
272
347
  getCacheDir: function getCacheDir() {
273
348
  return cachedir('Cypress');
@@ -294,7 +369,12 @@ var util = {
294
369
  la(_.isInteger(number), 'github issue should be an integer', number);
295
370
 
296
371
  return issuesUrl + '/' + number;
297
- }
372
+ },
373
+
374
+
375
+ getFileChecksum: getFileChecksum,
376
+
377
+ getFileSize: getFileSize
298
378
  };
299
379
 
300
380
  module.exports = util;
package/package.json CHANGED
@@ -1,18 +1,11 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "3.3.0",
3
+ "version": "3.4.1",
4
4
  "main": "index.js",
5
- "bin": {
6
- "cypress": "bin/cypress"
7
- },
8
- "engines": {
9
- "node": ">=4.0.0"
10
- },
11
5
  "scripts": {
12
6
  "postinstall": "node index.js --exec install",
13
7
  "size": "t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";"
14
8
  },
15
- "types": "types",
16
9
  "dependencies": {
17
10
  "@cypress/listr-verbose-renderer": "0.4.1",
18
11
  "@cypress/xvfb": "1.2.4",
@@ -27,20 +20,19 @@
27
20
  "execa": "0.10.0",
28
21
  "executable": "4.1.1",
29
22
  "extract-zip": "1.6.7",
30
- "fs-extra": "4.0.1",
23
+ "fs-extra": "5.0.0",
31
24
  "getos": "3.1.1",
32
- "glob": "7.1.3",
33
25
  "is-ci": "1.2.1",
34
26
  "is-installed-globally": "0.1.0",
35
27
  "lazy-ass": "1.6.0",
36
28
  "listr": "0.12.0",
37
- "lodash": "4.17.11",
29
+ "lodash": "4.17.15",
38
30
  "log-symbols": "2.2.0",
39
31
  "minimist": "1.2.0",
40
32
  "moment": "2.24.0",
41
33
  "ramda": "0.24.1",
42
34
  "request": "2.88.0",
43
- "request-progress": "0.4.0",
35
+ "request-progress": "3.0.0",
44
36
  "supports-color": "5.5.0",
45
37
  "tmp": "0.1.0",
46
38
  "url": "0.11.0",
@@ -52,6 +44,13 @@
52
44
  "index.js",
53
45
  "types/**/*.d.ts"
54
46
  ],
47
+ "bin": {
48
+ "cypress": "bin/cypress"
49
+ },
50
+ "engines": {
51
+ "node": ">=4.0.0"
52
+ },
53
+ "types": "types",
55
54
  "description": "Cypress.io end to end testing tool",
56
55
  "author": "Brian Mann",
57
56
  "homepage": "https://github.com/cypress-io/cypress",
@@ -64,18 +63,18 @@
64
63
  "url": "https://github.com/cypress-io/cypress.git"
65
64
  },
66
65
  "keywords": [
66
+ "automation",
67
67
  "browser",
68
68
  "cypress",
69
69
  "cypress.io",
70
- "automation",
71
- "end-to-end",
72
70
  "e2e",
71
+ "end-to-end",
73
72
  "integration",
74
73
  "mocks",
75
- "test",
76
- "testing",
77
74
  "runner",
78
75
  "spies",
79
- "stubs"
76
+ "stubs",
77
+ "test",
78
+ "testing"
80
79
  ]
81
80
  }
@@ -0,0 +1,51 @@
1
+ {
2
+ "_from": "@types/blob-util@1.3.3",
3
+ "_id": "@types/blob-util@1.3.3",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-4ahcL/QDnpjWA2Qs16ZMQif7HjGP2cw3AGjHabybjw7Vm1EKu+cfQN1D78BaZbS1WJNa1opSMF5HNMztx7lR0w==",
6
+ "_location": "/@types/blob-util",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "version",
10
+ "registry": true,
11
+ "raw": "@types/blob-util@1.3.3",
12
+ "name": "@types/blob-util",
13
+ "escapedName": "@types%2fblob-util",
14
+ "scope": "@types",
15
+ "rawSpec": "1.3.3",
16
+ "saveSpec": null,
17
+ "fetchSpec": "1.3.3"
18
+ },
19
+ "_requiredBy": [
20
+ "#DEV:/"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@types/blob-util/-/blob-util-1.3.3.tgz",
23
+ "_shasum": "adba644ae34f88e1dd9a5864c66ad651caaf628a",
24
+ "_spec": "@types/blob-util@1.3.3",
25
+ "_where": "/root/cypress/cli",
26
+ "bugs": {
27
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "contributors": [
31
+ {
32
+ "name": "Max Battcher",
33
+ "url": "https://github.com/WorldMaker"
34
+ }
35
+ ],
36
+ "dependencies": {},
37
+ "deprecated": false,
38
+ "description": "TypeScript definitions for blob-util",
39
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
40
+ "license": "MIT",
41
+ "main": "",
42
+ "name": "@types/blob-util",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
46
+ },
47
+ "scripts": {},
48
+ "typeScriptVersion": "2.1",
49
+ "typesPublisherContentHash": "251d66da417b64481e7f82fee1849478af0caa6fce0b1feee2146884d2dc9c98",
50
+ "version": "1.3.3"
51
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "_from": "@types/bluebird@3.5.18",
3
+ "_id": "@types/bluebird@3.5.18",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-OTPWHmsyW18BhrnG5x8F7PzeZ2nFxmHGb42bZn79P9hl+GI5cMzyPgQTwNjbem0lJhoru/8vtjAFCUOu3+gE2w==",
6
+ "_location": "/@types/bluebird",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "version",
10
+ "registry": true,
11
+ "raw": "@types/bluebird@3.5.18",
12
+ "name": "@types/bluebird",
13
+ "escapedName": "@types%2fbluebird",
14
+ "scope": "@types",
15
+ "rawSpec": "3.5.18",
16
+ "saveSpec": null,
17
+ "fetchSpec": "3.5.18"
18
+ },
19
+ "_requiredBy": [
20
+ "#DEV:/"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.18.tgz",
23
+ "_shasum": "6a60435d4663e290f3709898a4f75014f279c4d6",
24
+ "_spec": "@types/bluebird@3.5.18",
25
+ "_where": "/root/cypress/cli",
26
+ "bugs": {
27
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "contributors": [
31
+ {
32
+ "name": "Leonard Hecker",
33
+ "url": "https://github.com/lhecker"
34
+ }
35
+ ],
36
+ "dependencies": {},
37
+ "deprecated": false,
38
+ "description": "TypeScript definitions for bluebird",
39
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
40
+ "license": "MIT",
41
+ "main": "",
42
+ "name": "@types/bluebird",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
46
+ },
47
+ "scripts": {},
48
+ "typeScriptVersion": "2.3",
49
+ "typesPublisherContentHash": "c9b100367d31f8bd36031e55737d6ffde1a9b85dac3df3693f8f684f914c94cb",
50
+ "version": "3.5.18"
51
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "_from": "@types/chai@4.0.8",
3
+ "_id": "@types/chai@4.0.8",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-m812CONwdZn/dMzkIJEY0yAs4apyTkTORgfB2UsMOxgkUbC205AHnm4T8I0I5gPg9MHrFc1dJ35iS75c0CJkjg==",
6
+ "_location": "/@types/chai",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "version",
10
+ "registry": true,
11
+ "raw": "@types/chai@4.0.8",
12
+ "name": "@types/chai",
13
+ "escapedName": "@types%2fchai",
14
+ "scope": "@types",
15
+ "rawSpec": "4.0.8",
16
+ "saveSpec": null,
17
+ "fetchSpec": "4.0.8"
18
+ },
19
+ "_requiredBy": [
20
+ "#DEV:/",
21
+ "/@types/chai-jquery",
22
+ "/@types/sinon-chai"
23
+ ],
24
+ "_resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.8.tgz",
25
+ "_shasum": "d27600e9ba2f371e08695d90a0fe0408d89c7be7",
26
+ "_spec": "@types/chai@4.0.8",
27
+ "_where": "/root/cypress/cli",
28
+ "bugs": {
29
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
30
+ },
31
+ "bundleDependencies": false,
32
+ "contributors": [
33
+ {
34
+ "name": "Jed Mao",
35
+ "url": "https://github.com/jedmao"
36
+ },
37
+ {
38
+ "name": "Bart van der Schoor",
39
+ "url": "https://github.com/Bartvds"
40
+ },
41
+ {
42
+ "name": "Andrew Brown",
43
+ "url": "https://github.com/AGBrown"
44
+ },
45
+ {
46
+ "name": "Olivier Chevet",
47
+ "url": "https://github.com/olivr70"
48
+ },
49
+ {
50
+ "name": "Matt Wistrand",
51
+ "url": "https://github.com/mwistrand"
52
+ },
53
+ {
54
+ "name": "Josh Goldberg",
55
+ "url": "https://github.com/joshuakgoldberg"
56
+ },
57
+ {
58
+ "name": "Shaun Luttin",
59
+ "url": "https://github.com/shaunluttin"
60
+ },
61
+ {
62
+ "name": "Gintautas Miselis",
63
+ "url": "https://github.com/Naktibalda"
64
+ }
65
+ ],
66
+ "dependencies": {},
67
+ "deprecated": false,
68
+ "description": "TypeScript definitions for chai",
69
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
70
+ "license": "MIT",
71
+ "main": "",
72
+ "name": "@types/chai",
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
76
+ },
77
+ "scripts": {},
78
+ "typeScriptVersion": "2.0",
79
+ "typesPublisherContentHash": "1c89ea9e229c46de0cd9fc9a48b4ce18c27a3bab9d443d01bec054b1126ede4a",
80
+ "version": "4.0.8"
81
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "_from": "@types/chai-jquery@1.1.38",
3
+ "_id": "@types/chai-jquery@1.1.38",
4
+ "_inBundle": false,
5
+ "_integrity": "sha512-j/b++tOoQtkqXdkUWnojd+dM+YxkMiWJ193mToN/vv+rkBLv3MSSNwyDxFSXDwdi82Y+J2Js4fvdVkv/JiVeow==",
6
+ "_location": "/@types/chai-jquery",
7
+ "_phantomChildren": {},
8
+ "_requested": {
9
+ "type": "version",
10
+ "registry": true,
11
+ "raw": "@types/chai-jquery@1.1.38",
12
+ "name": "@types/chai-jquery",
13
+ "escapedName": "@types%2fchai-jquery",
14
+ "scope": "@types",
15
+ "rawSpec": "1.1.38",
16
+ "saveSpec": null,
17
+ "fetchSpec": "1.1.38"
18
+ },
19
+ "_requiredBy": [
20
+ "#DEV:/"
21
+ ],
22
+ "_resolved": "https://registry.npmjs.org/@types/chai-jquery/-/chai-jquery-1.1.38.tgz",
23
+ "_shasum": "bbab052200871e1b26b9a239caa63b2a2eaa00bc",
24
+ "_spec": "@types/chai-jquery@1.1.38",
25
+ "_where": "/root/cypress/cli",
26
+ "bugs": {
27
+ "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
28
+ },
29
+ "bundleDependencies": false,
30
+ "contributors": [
31
+ {
32
+ "name": "Kazi Manzur Rashid",
33
+ "url": "https://github.com/kazimanzurrashid"
34
+ }
35
+ ],
36
+ "dependencies": {
37
+ "@types/chai": "*",
38
+ "@types/jquery": "*"
39
+ },
40
+ "deprecated": false,
41
+ "description": "TypeScript definitions for chai-jquery",
42
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme",
43
+ "license": "MIT",
44
+ "main": "",
45
+ "name": "@types/chai-jquery",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
49
+ },
50
+ "scripts": {},
51
+ "typeScriptVersion": "2.3",
52
+ "types": "index",
53
+ "typesPublisherContentHash": "e12e44b47bd00c6f4a82ba74968fe19edad29fdcd0ffc07a23da854653181f17",
54
+ "version": "1.1.38"
55
+ }
@@ -1,12 +1,10 @@
1
1
  // Shim definition to export a namespace. Cypress is actually a global module
2
2
  // so import/export isn't allowed there. We import here and define a global module
3
3
  /// <reference path="./chai/index.d.ts" />
4
-
5
- export = Chai
6
- export as namespace Chai
7
-
8
4
  declare namespace Chai {
9
- type ChaiStatic = typeof chai
10
- type ExpectStatic = typeof chai.expect
11
- type AssertStatic = typeof chai.assert
5
+ interface Include {
6
+ html(html: string): Assertion
7
+ text(text: string): Assertion
8
+ value(text: string): Assertion
9
+ }
12
10
  }