Skip to content

Commit

Permalink
tests ~ improve 'integration.test.js' error feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Jul 31, 2022
1 parent 9750653 commit 443fac5
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

const fs = require('fs');
const path = require('path');
const util = require('util');

const test = require('ava');
const commandExists = require('command-exists');
Expand Down Expand Up @@ -67,11 +68,16 @@ if (!process.env.npm_config_test_dist) {
const args = ['run', '--allow-all', script];
const options = { shell: true, encoding: 'utf-8' };

t.log({ script });

const { error, status, stdout } = spawn.sync(command, args, options);

t.log({ error, status, stdout });
if (error === null && status === 0) {
t.log(
util.inspect(script, /* showHidden */ void 0, /* depth */ void 0, /* color */ true),
`(exit_status=${status})`
);
} else {
t.log({ script, error, status, stdout });
}

t.deepEqual({ error, status }, { error: null, status: 0 });
});
Expand All @@ -98,11 +104,16 @@ if (!process.env.npm_config_test_dist) {
const args = [script];
const options = { shell: true, encoding: 'utf-8' };

t.log({ script });

const { error, status, stdout } = spawn.sync(command, args, options);

t.log({ error, status, stdout });
if (error === null && status === 0) {
t.log(
util.inspect(script, /* showHidden */ void 0, /* depth */ void 0, /* color */ true),
`(exit_status=${status})`
);
} else {
t.log({ script, error, status, stdout });
}

t.deepEqual({ error, status }, { error: null, status: 0 });
}
Expand Down Expand Up @@ -133,16 +144,21 @@ if (!process.env.npm_config_test_dist) {
const args = ['node_modules/ts-node/dist/bin.js', script];
const options = { shell: true, encoding: 'utf8' };

const { error, status, stdout } = spawn.sync(command, args, options);

const basename = path.basename(file);
const extension = path.extname(file);
const name = path.basename(file, extension);
const nameExtension = path.extname(name);

t.log({ script, basename, name, extension, nameExtension });

const { error, status, stdout } = spawn.sync(command, args, options);

t.log({ error, status, stdout });
if (error === null && status === 0) {
t.log(
util.inspect(script, /* showHidden */ void 0, /* depth */ void 0, /* color */ true),
`(exit_status=${status})`
);
} else {
t.log({ script, basename, name, extension, nameExtension, error, status, stdout });
}

t.deepEqual({ error, status }, { error: null, status: 0 });
}
Expand Down

0 comments on commit 443fac5

Please sign in to comment.