Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUIT-8895 Fixed unit tests for testLauncher/index.test.js. #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/chains/networkRequestChain.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const toString = data => {
comparator && comparator.type === SUBJ_COMPARATOR.CONTAIN
);

return template(comparator.val, getTimeoutValue(data));
return template(comparator && comparator.val, getTimeoutValue(data));
};

const toJSON = data => {
Expand Down
4 changes: 2 additions & 2 deletions lib/testLauncher/SuitestLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ class SuitestLauncher {
// log all devices logs
Object.keys(devicesLogs).forEach(dId => log.deviceLines(devicesLogs[dId], dId));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite critical fix

const failedDevices = result.filter(res => res.error || res.code !== 0);
const failedDevices = result.filter(res => res.result.error || res.result.code !== 0);

// log final result
log.finalAutomated(failedDevices.length, result.length - failedDevices.length);
handleChildResult(failedDevices.length !== result.length);
handleChildResult(failedDevices.length - result.length >= 0);
resolve();
}));
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/testHelpers/testLauncherTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ nock(config.apiUrl)
{
deviceAccessToken: 'deviceAccessToken',
testPack: {
devices: [{deviceId: 1}],
devices: [{deviceId: '1'}],
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/unusedExpressionWatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const warnUnusedLeaves = () => {
for (const chain of unusedLeaves) {
const leafData = unusedLeavesData.get(chain);

output.push(`${chain.toString()} in ${leafData.file} on line ${leafData.line}`);
output.push(`${chain && chain.toString()} in ${leafData.file} on line ${leafData.line}`);
}

if (output.length) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"read": "^1.0.7",
"stack-trace": "^0.0.10",
"uuid": "^3.2.1",
"ws": "^4.0.0",
"ws": "^5.1.1",
"yargs": "^11.0.0",
"yargs-parser": "^9.0.2"
}
Expand Down
4 changes: 2 additions & 2 deletions test/api/webSockets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const webSockets = require('../../lib/api/webSockets');
const SuitestError = require('../../lib/utils/SuitestError');

describe('webSockets', () => {
before(async() => {
await testServer.start();
beforeEach(async() => {
await testServer.restart();
});

after(async() => {
Expand Down
26 changes: 15 additions & 11 deletions test/testLauncher/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ const {authContext} = require('../../lib/context');
const testServer = require('../../lib/utils/testServer');
const texts = require('../../lib/texts');

const testLauncherTest = path.resolve(__dirname, '../../lib/utils/testHelpers/testLauncherTest.js');
const testLauncherTest = processExecPath(path.resolve(__dirname, '../../lib/utils/testHelpers/testLauncherTest.js'));
const spawn = require('child_process').spawn;

function processExecPath(execPath) {
return /\s+/.test(execPath) ? `"${execPath}"` : execPath;
}

describe('suitest test launcher', function() {
this.timeout(5000); // increase timeout limit for current test suite

Expand All @@ -28,7 +32,7 @@ describe('suitest test launcher', function() {

it('"automated" command should exit with exitCode 0', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'automated', '-p', 'a', '-k', 'a', '--testPackId', '10', 'npm', '--version'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -39,7 +43,7 @@ describe('suitest test launcher', function() {

it('"automated" command should exit with exitCode 1 if required args not provided', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'automated'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -50,7 +54,7 @@ describe('suitest test launcher', function() {

it('"automated" command should exit with exitCode 0 if --version option provided', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'automated', '--version'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -61,7 +65,7 @@ describe('suitest test launcher', function() {

it('"automated" command should exit with exitCode 1 if no devices in response', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'automated', '-p', 'a', '-k', 'a', '--testPackId', '20', 'npm', '--version'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -72,7 +76,7 @@ describe('suitest test launcher', function() {

it('"interactive" command should exit with exitCode 0', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[
testLauncherTest, 'interactive', '-u', 'userEmail', '-p', 'userPass',
'-o', 'orgId', '-C', 'configId', '-d', 'deviceId', 'npm', '--version',
Expand All @@ -86,7 +90,7 @@ describe('suitest test launcher', function() {

it('"interactive" command should exit with exitCode 1 if required args not provided', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'interactive', '-p', 'pass'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -98,7 +102,7 @@ describe('suitest test launcher', function() {
it('"interactive" command should ask for user password if not provided', (done) => {
let passProvided = false;
const child = spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'interactive'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -123,7 +127,7 @@ describe('suitest test launcher', function() {
let passProvided = false;

const child = spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'interactive'],
{shell: true}
).once('exit', (exitCode) => {
Expand Down Expand Up @@ -152,7 +156,7 @@ describe('suitest test launcher', function() {
let passProvided = false;

const child = spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'interactive'],
{shell: true}
).once('exit', (exitCode) => {
Expand All @@ -174,7 +178,7 @@ describe('suitest test launcher', function() {

it('"interactive" command should exit with exitCode 0 if calle with --help option', (done) => {
spawn(
process.execPath,
processExecPath(process.execPath),
[testLauncherTest, 'interactive', '-h'],
{shell: true}
).once('exit', (exitCode) => {
Expand Down
Loading