cypress 15.0.0 → 15.2.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/bin/cypress +3 -1
- package/index.js +49 -24
- package/lib/VerboseRenderer.js +50 -47
- package/lib/cli.js +455 -351
- package/lib/cypress.js +93 -90
- package/lib/errors.js +181 -194
- package/lib/exec/info.js +85 -74
- package/lib/exec/open.js +77 -73
- package/lib/exec/run.js +144 -154
- package/lib/exec/shared.js +37 -44
- package/lib/exec/spawn.js +270 -232
- package/lib/exec/versions.js +57 -49
- package/lib/exec/xvfb.js +79 -81
- package/lib/fs.js +7 -3
- package/lib/logger.js +37 -32
- package/lib/tasks/cache.js +128 -113
- package/lib/tasks/download.js +247 -258
- package/lib/tasks/get-folder-size.js +33 -22
- package/lib/tasks/install.js +274 -312
- package/lib/tasks/state.js +132 -143
- package/lib/tasks/unzip.js +186 -188
- package/lib/tasks/verify.js +274 -261
- package/lib/util.js +357 -356
- package/package.json +7 -4
- package/react/package.json +1 -1
- package/react/react/package.json +1 -1
- package/types/cypress-automation.d.ts +18 -0
- package/types/cypress.d.ts +15 -2
- package/types/index.d.ts +1 -1
- package/vue/package.json +1 -1
- package/vue/vue/package.json +1 -1
package/lib/tasks/verify.js
CHANGED
@@ -1,288 +1,301 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
const
|
9
|
-
const
|
10
|
-
|
11
|
-
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
const
|
22
|
-
const
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
const checkExecutable = binaryDir => {
|
27
|
-
const executable = state.getPathToExecutable(binaryDir);
|
28
|
-
debug('checking if executable exists', executable);
|
29
|
-
return util.isExecutableAsync(executable).then(isExecutable => {
|
30
|
-
debug('Binary is executable? :', isExecutable);
|
31
|
-
if (!isExecutable) {
|
32
|
-
return throwFormErrorText(errors.binaryNotExecutable(executable))();
|
33
|
-
}
|
34
|
-
}).catch({
|
35
|
-
code: 'ENOENT'
|
36
|
-
}, () => {
|
37
|
-
if (util.isCi()) {
|
38
|
-
return throwFormErrorText(errors.notInstalledCI(executable))();
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const lodash_1 = __importDefault(require("lodash"));
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
8
|
+
const listr2_1 = require("listr2");
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
10
|
+
const common_tags_1 = require("common-tags");
|
11
|
+
const bluebird_1 = __importDefault(require("bluebird"));
|
12
|
+
const log_symbols_1 = __importDefault(require("log-symbols"));
|
13
|
+
const path_1 = __importDefault(require("path"));
|
14
|
+
const os_1 = __importDefault(require("os"));
|
15
|
+
const VerboseRenderer_1 = __importDefault(require("../VerboseRenderer"));
|
16
|
+
const errors_1 = require("../errors");
|
17
|
+
const util_1 = __importDefault(require("../util"));
|
18
|
+
const logger_1 = __importDefault(require("../logger"));
|
19
|
+
const xvfb_1 = __importDefault(require("../exec/xvfb"));
|
20
|
+
const state_1 = __importDefault(require("./state"));
|
21
|
+
const debug = (0, debug_1.default)('cypress:cli');
|
22
|
+
const VERIFY_TEST_RUNNER_TIMEOUT_MS = (() => {
|
23
|
+
const verifyTimeout = +((util_1.default === null || util_1.default === void 0 ? void 0 : util_1.default.getEnv('CYPRESS_VERIFY_TIMEOUT')) || 'NaN');
|
24
|
+
if (lodash_1.default.isNumber(verifyTimeout) && !lodash_1.default.isNaN(verifyTimeout)) {
|
25
|
+
return verifyTimeout;
|
39
26
|
}
|
40
|
-
return
|
41
|
-
|
27
|
+
return 30000;
|
28
|
+
})();
|
29
|
+
const checkExecutable = (binaryDir) => {
|
30
|
+
const executable = state_1.default.getPathToExecutable(binaryDir);
|
31
|
+
debug('checking if executable exists', executable);
|
32
|
+
return util_1.default.isExecutableAsync(executable)
|
33
|
+
.then((isExecutable) => {
|
34
|
+
debug('Binary is executable? :', isExecutable);
|
35
|
+
if (!isExecutable) {
|
36
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.binaryNotExecutable(executable))();
|
37
|
+
}
|
38
|
+
})
|
39
|
+
.catch({ code: 'ENOENT' }, () => {
|
40
|
+
if (util_1.default.isCi()) {
|
41
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.notInstalledCI(executable))();
|
42
|
+
}
|
43
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.missingApp(binaryDir))((0, common_tags_1.stripIndent) `
|
44
|
+
Cypress executable not found at: ${chalk_1.default.cyan(executable)}
|
42
45
|
`);
|
43
|
-
|
46
|
+
});
|
44
47
|
};
|
45
48
|
const runSmokeTest = (binaryDir, options) => {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
let executable = state_1.default.getPathToExecutable(binaryDir);
|
50
|
+
const onSmokeTestError = (smokeTestCommand, linuxWithDisplayEnv) => {
|
51
|
+
return (err) => {
|
52
|
+
debug('Smoke test failed:', err);
|
53
|
+
let errMessage = err.stderr || err.message;
|
54
|
+
debug('error message:', errMessage);
|
55
|
+
if (err.timedOut) {
|
56
|
+
debug('error timedOut is true');
|
57
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.smokeTestFailure(smokeTestCommand, true))(errMessage);
|
58
|
+
}
|
59
|
+
if (linuxWithDisplayEnv && util_1.default.isBrokenGtkDisplay(errMessage)) {
|
60
|
+
util_1.default.logBrokenGtkDisplayWarning();
|
61
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.invalidSmokeTestDisplayError)(errMessage);
|
62
|
+
}
|
63
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.missingDependency)(errMessage);
|
64
|
+
};
|
61
65
|
};
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
66
|
+
const needsXvfb = xvfb_1.default.isNeeded();
|
67
|
+
debug('needs Xvfb?', needsXvfb);
|
68
|
+
/**
|
69
|
+
* Spawn Cypress running smoke test to check if all operating system
|
70
|
+
* dependencies are good.
|
71
|
+
*/
|
72
|
+
const spawn = (linuxWithDisplayEnv) => {
|
73
|
+
const random = lodash_1.default.random(0, 1000);
|
74
|
+
const args = ['--smoke-test', `--ping=${random}`];
|
75
|
+
if (needsSandbox()) {
|
76
|
+
// electron requires --no-sandbox to run as root
|
77
|
+
debug('disabling Electron sandbox');
|
78
|
+
args.unshift('--no-sandbox');
|
79
|
+
}
|
80
|
+
if (options.dev) {
|
81
|
+
executable = 'node';
|
82
|
+
args.unshift(path_1.default.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'));
|
83
|
+
}
|
84
|
+
const smokeTestCommand = `${executable} ${args.join(' ')}`;
|
85
|
+
debug('running smoke test');
|
86
|
+
debug('using Cypress executable %s', executable);
|
87
|
+
debug('smoke test command:', smokeTestCommand);
|
88
|
+
debug('smoke test timeout %d ms', options.smokeTestTimeout);
|
89
|
+
const stdioOptions = lodash_1.default.extend({}, {
|
90
|
+
env: Object.assign(Object.assign({}, process.env), { FORCE_COLOR: '0' }),
|
91
|
+
timeout: options.smokeTestTimeout,
|
92
|
+
});
|
93
|
+
return bluebird_1.default.resolve(util_1.default.exec(executable, args, stdioOptions))
|
94
|
+
.catch(onSmokeTestError(smokeTestCommand, linuxWithDisplayEnv))
|
95
|
+
.then((result) => {
|
96
|
+
// TODO: when execa > 1.1 is released
|
97
|
+
// change this to `result.all` for both stderr and stdout
|
98
|
+
// use lodash to be robust during tests against null result or missing stdout
|
99
|
+
const smokeTestStdout = lodash_1.default.get(result, 'stdout', '');
|
100
|
+
debug('smoke test stdout "%s"', smokeTestStdout);
|
101
|
+
if (!util_1.default.stdoutLineMatches(String(random), smokeTestStdout)) {
|
102
|
+
debug('Smoke test failed because could not find %d in:', random, result);
|
103
|
+
const smokeTestStderr = lodash_1.default.get(result, 'stderr', '');
|
104
|
+
const errorText = smokeTestStderr || smokeTestStdout;
|
105
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.smokeTestFailure(smokeTestCommand, false))(errorText);
|
106
|
+
}
|
107
|
+
});
|
108
|
+
};
|
109
|
+
const spawnInXvfb = (linuxWithDisplayEnv) => {
|
110
|
+
return xvfb_1.default
|
111
|
+
.start()
|
112
|
+
.then(() => {
|
113
|
+
return spawn(linuxWithDisplayEnv || false);
|
114
|
+
})
|
115
|
+
.finally(xvfb_1.default.stop);
|
116
|
+
};
|
117
|
+
const userFriendlySpawn = (linuxWithDisplayEnv) => {
|
118
|
+
debug('spawning, should retry on display problem?', Boolean(linuxWithDisplayEnv));
|
119
|
+
return spawn(linuxWithDisplayEnv)
|
120
|
+
.catch({ code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR' }, () => {
|
121
|
+
return spawnInXvfb(linuxWithDisplayEnv);
|
122
|
+
});
|
123
|
+
};
|
124
|
+
if (needsXvfb) {
|
125
|
+
return spawnInXvfb();
|
81
126
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
const stdioOptions = _.extend({}, {
|
88
|
-
env: {
|
89
|
-
...process.env,
|
90
|
-
FORCE_COLOR: 0
|
91
|
-
},
|
92
|
-
timeout: options.smokeTestTimeout
|
93
|
-
});
|
94
|
-
return Promise.resolve(util.exec(executable, args, stdioOptions)).catch(onSmokeTestError(smokeTestCommand, linuxWithDisplayEnv)).then(result => {
|
95
|
-
// TODO: when execa > 1.1 is released
|
96
|
-
// change this to `result.all` for both stderr and stdout
|
97
|
-
// use lodash to be robust during tests against null result or missing stdout
|
98
|
-
const smokeTestStdout = _.get(result, 'stdout', '');
|
99
|
-
debug('smoke test stdout "%s"', smokeTestStdout);
|
100
|
-
if (!util.stdoutLineMatches(String(random), smokeTestStdout)) {
|
101
|
-
debug('Smoke test failed because could not find %d in:', random, result);
|
102
|
-
const smokeTestStderr = _.get(result, 'stderr', '');
|
103
|
-
const errorText = smokeTestStderr || smokeTestStdout;
|
104
|
-
return throwFormErrorText(errors.smokeTestFailure(smokeTestCommand, false))(errorText);
|
105
|
-
}
|
106
|
-
});
|
107
|
-
};
|
108
|
-
const spawnInXvfb = linuxWithDisplayEnv => {
|
109
|
-
return xvfb.start().then(() => {
|
110
|
-
return spawn(linuxWithDisplayEnv);
|
111
|
-
}).finally(xvfb.stop);
|
112
|
-
};
|
113
|
-
const userFriendlySpawn = linuxWithDisplayEnv => {
|
114
|
-
debug('spawning, should retry on display problem?', Boolean(linuxWithDisplayEnv));
|
115
|
-
return spawn(linuxWithDisplayEnv).catch({
|
116
|
-
code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR'
|
117
|
-
}, () => {
|
118
|
-
return spawnInXvfb(linuxWithDisplayEnv);
|
119
|
-
});
|
120
|
-
};
|
121
|
-
if (needsXvfb) {
|
122
|
-
return spawnInXvfb();
|
123
|
-
}
|
124
|
-
|
125
|
-
// if we are on linux and there's already a DISPLAY
|
126
|
-
// set, then we may need to rerun cypress after
|
127
|
-
// spawning our own Xvfb server
|
128
|
-
const linuxWithDisplayEnv = util.isPossibleLinuxWithIncorrectDisplay();
|
129
|
-
return userFriendlySpawn(linuxWithDisplayEnv);
|
127
|
+
// if we are on linux and there's already a DISPLAY
|
128
|
+
// set, then we may need to rerun cypress after
|
129
|
+
// spawning our own Xvfb server
|
130
|
+
const linuxWithDisplayEnv = util_1.default.isPossibleLinuxWithIncorrectDisplay();
|
131
|
+
return userFriendlySpawn(linuxWithDisplayEnv);
|
130
132
|
};
|
131
133
|
function testBinary(version, binaryDir, options) {
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
It looks like this is your first time using Cypress: ${chalk.cyan(version)}
|
134
|
+
debug('running binary verification check', version);
|
135
|
+
// if running from 'cypress verify', don't print this message
|
136
|
+
if (!options.force) {
|
137
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
138
|
+
It looks like this is your first time using Cypress: ${chalk_1.default.cyan(version)}
|
138
139
|
`);
|
139
|
-
}
|
140
|
-
logger.log();
|
141
|
-
|
142
|
-
// if we are running in CI then use
|
143
|
-
// the verbose renderer else use
|
144
|
-
// the default
|
145
|
-
let renderer = util.isCi() ? verbose : 'default';
|
146
|
-
if (logger.logLevel() === 'silent') renderer = 'silent';
|
147
|
-
const rendererOptions = {
|
148
|
-
renderer
|
149
|
-
};
|
150
|
-
const tasks = new Listr([{
|
151
|
-
options: {
|
152
|
-
title: util.titleize('Verifying Cypress can run', chalk.gray(binaryDir))
|
153
|
-
},
|
154
|
-
task: (ctx, task) => {
|
155
|
-
debug('clearing out the verified version');
|
156
|
-
return state.clearBinaryStateAsync(binaryDir).then(() => {
|
157
|
-
return Promise.all([runSmokeTest(binaryDir, options), Promise.resolve().delay(1500) // good user experience
|
158
|
-
]);
|
159
|
-
}).then(() => {
|
160
|
-
debug('write verified: true');
|
161
|
-
return state.writeBinaryVerifiedAsync(true, binaryDir);
|
162
|
-
}).then(() => {
|
163
|
-
util.setTaskTitle(task, util.titleize(chalk.green('Verified Cypress!'), chalk.gray(binaryDir)), rendererOptions.renderer);
|
164
|
-
});
|
165
140
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
141
|
+
logger_1.default.log();
|
142
|
+
// if we are running in CI then use
|
143
|
+
// the verbose renderer else use
|
144
|
+
// the default
|
145
|
+
let renderer = util_1.default.isCi() ? VerboseRenderer_1.default : 'default';
|
146
|
+
// NOTE: under test we set the listr renderer to 'silent' in order to get deterministic snapshots
|
147
|
+
if (logger_1.default.logLevel() === 'silent' || options.listrRenderer)
|
148
|
+
renderer = 'silent';
|
149
|
+
const rendererOptions = {
|
150
|
+
renderer,
|
151
|
+
};
|
152
|
+
const tasks = new listr2_1.Listr([
|
153
|
+
{
|
154
|
+
title: util_1.default.titleize('Verifying Cypress can run', chalk_1.default.gray(binaryDir)),
|
155
|
+
task: (ctx, task) => {
|
156
|
+
debug('clearing out the verified version');
|
157
|
+
return state_1.default.clearBinaryStateAsync(binaryDir)
|
158
|
+
.then(() => {
|
159
|
+
return bluebird_1.default.all([
|
160
|
+
runSmokeTest(binaryDir, options),
|
161
|
+
bluebird_1.default.delay(1500), // good user experience
|
162
|
+
]);
|
163
|
+
})
|
164
|
+
.then(() => {
|
165
|
+
debug('write verified: true');
|
166
|
+
return state_1.default.writeBinaryVerifiedAsync(true, binaryDir);
|
167
|
+
})
|
168
|
+
.then(() => {
|
169
|
+
util_1.default.setTaskTitle(task, util_1.default.titleize(chalk_1.default.green('Verified Cypress!'), chalk_1.default.gray(binaryDir)), rendererOptions.renderer);
|
170
|
+
});
|
171
|
+
},
|
172
|
+
},
|
173
|
+
], rendererOptions);
|
174
|
+
return tasks.run();
|
170
175
|
}
|
171
176
|
const maybeVerify = (installedVersion, binaryDir, options) => {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
}
|
181
|
-
if (shouldVerify) {
|
182
|
-
return testBinary(installedVersion, binaryDir, options).then(() => {
|
183
|
-
if (options.welcomeMessage) {
|
184
|
-
logger.log();
|
185
|
-
logger.log('Opening Cypress...');
|
177
|
+
return state_1.default.getBinaryVerifiedAsync(binaryDir)
|
178
|
+
.then((isVerified) => {
|
179
|
+
debug('is Verified ?', isVerified);
|
180
|
+
let shouldVerify = !isVerified;
|
181
|
+
// force verify if options.force
|
182
|
+
if (options.force) {
|
183
|
+
debug('force verify');
|
184
|
+
shouldVerify = true;
|
186
185
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
186
|
+
if (shouldVerify) {
|
187
|
+
return testBinary(installedVersion, binaryDir, options)
|
188
|
+
.then(() => {
|
189
|
+
if (options.welcomeMessage) {
|
190
|
+
logger_1.default.log();
|
191
|
+
logger_1.default.log('Opening Cypress...');
|
192
|
+
}
|
193
|
+
});
|
194
|
+
}
|
195
|
+
});
|
190
196
|
};
|
191
197
|
const start = (options = {}) => {
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
${
|
198
|
+
debug('verifying Cypress app');
|
199
|
+
const packageVersion = util_1.default.pkgVersion();
|
200
|
+
let binaryDir = state_1.default.getBinaryDir(packageVersion);
|
201
|
+
lodash_1.default.defaults(options, {
|
202
|
+
dev: false,
|
203
|
+
force: false,
|
204
|
+
welcomeMessage: true,
|
205
|
+
smokeTestTimeout: VERIFY_TEST_RUNNER_TIMEOUT_MS,
|
206
|
+
skipVerify: util_1.default.getEnv('CYPRESS_SKIP_VERIFY') === 'true',
|
207
|
+
});
|
208
|
+
if (options.skipVerify) {
|
209
|
+
debug('skipping verification of the Cypress app');
|
210
|
+
return bluebird_1.default.resolve();
|
211
|
+
}
|
212
|
+
if (options.dev) {
|
213
|
+
return runSmokeTest('', options);
|
214
|
+
}
|
215
|
+
const parseBinaryEnvVar = () => {
|
216
|
+
const envBinaryPath = util_1.default.getEnv('CYPRESS_RUN_BINARY');
|
217
|
+
debug('CYPRESS_RUN_BINARY exists, =', envBinaryPath);
|
218
|
+
logger_1.default.log((0, common_tags_1.stripIndent) `
|
219
|
+
${chalk_1.default.yellow('Note:')} You have set the environment variable:
|
214
220
|
|
215
|
-
${
|
221
|
+
${chalk_1.default.white('CYPRESS_RUN_BINARY=')}${chalk_1.default.cyan(envBinaryPath)}
|
216
222
|
|
217
223
|
This overrides the default Cypress binary path used.
|
218
224
|
`);
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
225
|
+
logger_1.default.log();
|
226
|
+
return util_1.default.isExecutableAsync(envBinaryPath)
|
227
|
+
.then((isExecutable) => {
|
228
|
+
debug('CYPRESS_RUN_BINARY is executable? :', isExecutable);
|
229
|
+
if (!isExecutable) {
|
230
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))((0, common_tags_1.stripIndent) `
|
224
231
|
The supplied binary path is not executable
|
225
232
|
`);
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
233
|
+
}
|
234
|
+
})
|
235
|
+
.then(() => {
|
236
|
+
return state_1.default.parseRealPlatformBinaryFolderAsync(envBinaryPath);
|
237
|
+
})
|
238
|
+
.then((envBinaryDir) => {
|
239
|
+
if (!envBinaryDir) {
|
240
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))();
|
241
|
+
}
|
242
|
+
debug('CYPRESS_RUN_BINARY has binaryDir:', envBinaryDir);
|
243
|
+
binaryDir = envBinaryDir;
|
244
|
+
})
|
245
|
+
.catch({ code: 'ENOENT' }, (err) => {
|
246
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.CYPRESS_RUN_BINARY.notValid(envBinaryPath))(err.message);
|
247
|
+
});
|
248
|
+
};
|
249
|
+
return bluebird_1.default.try(() => {
|
250
|
+
debug('checking environment variables');
|
251
|
+
if (util_1.default.getEnv('CYPRESS_RUN_BINARY')) {
|
252
|
+
return parseBinaryEnvVar();
|
253
|
+
}
|
254
|
+
})
|
255
|
+
.then(() => {
|
256
|
+
return checkExecutable(binaryDir);
|
257
|
+
})
|
258
|
+
.tap(() => {
|
259
|
+
return debug('binaryDir is ', binaryDir);
|
260
|
+
})
|
261
|
+
.then(() => {
|
262
|
+
return state_1.default.getBinaryPkgAsync(binaryDir);
|
263
|
+
})
|
264
|
+
.then((pkg) => {
|
265
|
+
return state_1.default.getBinaryPkgVersion(pkg);
|
266
|
+
})
|
267
|
+
.then((binaryVersion) => {
|
268
|
+
if (!binaryVersion) {
|
269
|
+
debug('no Cypress binary found for cli version ', packageVersion);
|
270
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.missingApp(binaryDir))(`
|
271
|
+
Cannot read binary version from: ${chalk_1.default.cyan(state_1.default.getBinaryPkgPath(binaryDir))}
|
259
272
|
`);
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
273
|
+
}
|
274
|
+
debug(`Found binary version ${chalk_1.default.green(binaryVersion)} installed in: ${chalk_1.default.cyan(binaryDir)}`);
|
275
|
+
if (binaryVersion !== packageVersion) {
|
276
|
+
// warn if we installed with CYPRESS_INSTALL_BINARY or changed version
|
277
|
+
// in the package.json
|
278
|
+
logger_1.default.log(`Found binary version ${chalk_1.default.green(binaryVersion)} installed in: ${chalk_1.default.cyan(binaryDir)}`);
|
279
|
+
logger_1.default.log();
|
280
|
+
logger_1.default.warn((0, common_tags_1.stripIndent) `
|
268
281
|
|
269
282
|
|
270
|
-
${
|
283
|
+
${log_symbols_1.default.warning} Warning: Binary version ${chalk_1.default.green(binaryVersion)} does not match the expected package version ${chalk_1.default.green(packageVersion)}
|
271
284
|
|
272
285
|
These versions may not work properly together.
|
273
286
|
`);
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
287
|
+
logger_1.default.log();
|
288
|
+
}
|
289
|
+
return maybeVerify(binaryVersion, binaryDir, options);
|
290
|
+
})
|
291
|
+
.catch((err) => {
|
292
|
+
if (err.known) {
|
293
|
+
throw err;
|
294
|
+
}
|
295
|
+
return (0, errors_1.throwFormErrorText)(errors_1.errors.unexpected)(err.stack);
|
296
|
+
});
|
283
297
|
};
|
284
|
-
const isLinuxLike = () =>
|
285
|
-
|
298
|
+
const isLinuxLike = () => os_1.default.platform() !== 'win32';
|
286
299
|
/**
|
287
300
|
* Returns true if running on a system where Electron needs "--no-sandbox" flag.
|
288
301
|
* @see https://crbug.com/638180
|
@@ -293,8 +306,8 @@ const isLinuxLike = () => os.platform() !== 'win32';
|
|
293
306
|
* @see https://github.com/electron/electron/issues/17972
|
294
307
|
*/
|
295
308
|
const needsSandbox = () => isLinuxLike();
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
};
|
309
|
+
exports.default = {
|
310
|
+
start,
|
311
|
+
needsSandbox,
|
312
|
+
VERIFY_TEST_RUNNER_TIMEOUT_MS,
|
313
|
+
};
|