Skip to content

Commit

Permalink
Printing environment variables before jest test command (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Jul 25, 2018
1 parent 1daa65d commit dff3082
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions detox/local-cli/detox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function runJest() {
const platformString = platform ? shellQuote(`--testNamePattern=^((?!${getPlatformSpecificString(platform)}).)*$`) : '';
const binPath = path.join('node_modules', '.bin', 'jest');
const command = `${binPath} ${testFolder} ${configFile} --maxWorkers=${program.workers} ${platformString}`;
const env = Object.assign({}, process.env, {
const detoxEnvironmentVariables = {
configuration: program.configuration,
loglevel: program.loglevel,
cleanup: program.cleanup,
Expand All @@ -140,15 +140,28 @@ function runJest() {
recordLogs: program.recordLogs,
takeScreenshots: program.takeScreenshots,
recordVideos: program.recordVideos,
});
};

console.log(command);
console.log(printEnvironmentVariables(detoxEnvironmentVariables) + command);
cp.execSync(command, {
stdio: 'inherit',
env,
env: {
...process.env,
...detoxEnvironmentVariables,
},
});
}

function printEnvironmentVariables(envObject) {
return Object.entries(envObject).reduce((cli, [key, value]) => {
if (value === null || value === undefined || value === '') {
return cli;
}

return `${cli}${key}=${JSON.stringify(value)} `;
}, '');
}

function getDefaultRunnerConfig() {
let defaultConfig;
switch (runner) {
Expand Down Expand Up @@ -193,4 +206,4 @@ function shellQuote(input) {
return process.platform !== 'win32' ? `'${input}'` : `"${input}"`;
}

run();
run();

0 comments on commit dff3082

Please sign in to comment.