Files
Detox/detox/test/scripts/verify_artifacts_are_not_missing.js
2018-11-06 22:25:01 +02:00

33 lines
856 B
JavaScript

const _ = require('lodash');
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
module.exports = function verify(configuration) {
let startupLogs = 0;
let textLogs = 0;
let jsonLogs = 0;
const subdir = _.last(_.filter(fs.readdirSync('artifacts'), (str) => str.includes(configuration)));
const artifacts = cp.execSync(`find .`, {
cwd: path.join('artifacts', subdir),
encoding: 'utf8'
}).split('\n').map((filename) => {
if (filename.endsWith('.startup.log')) {
return `${++startupLogs}.startup.log`;
}
if (filename.match(/detox_pid_\d+.log$/)) {
return `${++textLogs}.detox.log`;
}
if (filename.match(/detox_pid_\d+.json.log$/)) {
return `${++jsonLogs}.detox.json.log`;
}
return filename;
}).sort();
expect(artifacts).toMatchSnapshot();
};