Skip to content

Commit

Permalink
fix(scripts): jest pass-fail bug (#944)
Browse files Browse the repository at this point in the history
* fix(scripts): fix jest pass-fail bug

* add trim
  • Loading branch information
TarikGul committed Jun 16, 2022
1 parent bb5dea9 commit 44482aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IChainConfig } from './types';
const defaultJestOpts = {
proc: 'jest',
resolver: 'PASS',
resolverJestErr: 'FAIL',
};

export const defaultSasStartOpts = {
Expand Down
11 changes: 8 additions & 3 deletions scripts/sidecarScriptApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ export const killAll = (procs: ProcsType): void => {
export const launchProcess = (
cmd: string,
procs: ProcsType,
{ proc, resolver, resolverStartupErr, args }: IProcOpts
{ proc, resolver, resolverJestErr, resolverStartupErr, args }: IProcOpts
): Promise<StatusCode> => {
return new Promise<StatusCode>((resolve, reject) => {
const { Success, Failed } = StatusCode;

const command = cmd || 'yarn';
let jestStatus = Success;

procs[proc] = spawn(command, args, { detached: true });

Expand All @@ -103,12 +103,17 @@ export const launchProcess = (
procs[proc].stderr.on('data', (data: Buffer) => {
console.error(data.toString().trim());

if (resolverStartupErr && data.toString().includes(resolverStartupErr)) {
if (resolverJestErr && data.toString().trim().includes(resolverJestErr)) {
jestStatus = Failed;
}

if (resolverStartupErr && data.toString().trim().includes(resolverStartupErr)) {
resolve(Failed);
}
});

procs[proc].on('close', () => {
if (jestStatus === Failed) resolve(Failed);
resolve(Success);
});

Expand Down
1 change: 1 addition & 0 deletions scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export interface IProcOpts {
proc: string;
resolver: string;
resolverStartupErr?: string;
resolverJestErr?: string;
args: string[];
}

0 comments on commit 44482aa

Please sign in to comment.