Skip to content

Commit

Permalink
fix: debug info causes error (#3882)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Oct 6, 2023
1 parent e0ac568 commit 963e847
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
24 changes: 24 additions & 0 deletions lib/command/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ module.exports = async function (path) {
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues');
output.print('***************************************');
};

module.exports.getMachineInfo = async () => {
const info = {
nodeInfo: await envinfo.helpers.getNodeInfo(),
osInfo: await envinfo.helpers.getOSInfo(),
cpuInfo: await envinfo.helpers.getCPUInfo(),
chromeInfo: await envinfo.helpers.getChromeInfo(),
edgeInfo: await envinfo.helpers.getEdgeInfo(),
firefoxInfo: await envinfo.helpers.getFirefoxInfo(),
safariInfo: await envinfo.helpers.getSafariInfo(),
};

output.print('***************************************');
for (const [key, value] of Object.entries(info)) {
if (Array.isArray(value)) {
output.print(`${key}: ${value[1]}`);
} else {
output.print(`${key}: ${JSON.stringify(value, null, ' ')}`);
}
}
output.print('If you need more detailed info, just run this: npx codeceptjs info');
output.print('***************************************');
return info;
};
4 changes: 2 additions & 2 deletions lib/command/run-workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module.exports = async function (workerCount, selectedRuns, options) {

try {
if (options.verbose) {
const getInfo = require('./info');
await getInfo();
const { getMachineInfo } = require('./info');
await getMachineInfo();
}
await workers.bootstrapAll();
await workers.run();
Expand Down
4 changes: 2 additions & 2 deletions lib/command/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module.exports = async function (test, options) {
codecept.loadTests(test);

if (options.verbose) {
const getInfo = require('./info');
await getInfo();
const { getMachineInfo } = require('./info');
await getMachineInfo();
}

await codecept.run();
Expand Down
3 changes: 1 addition & 2 deletions test/runner/interface_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ describe('CodeceptJS Interface', () => {
it('should not propagate retries to non retried steps', (done) => {
exec(`${config_run_config('codecept.retry.json')} --grep @test2 --verbose`, (err, stdout) => {
expect(stdout).toContain('Retry'); // feature
expect(stdout).toContain('Retries: 5'); // test name
expect(err).toBeFalsy();
expect(stdout).toContain('Retries: 1'); // test name
done();
});
});
Expand Down

0 comments on commit 963e847

Please sign in to comment.