Skip to content

Commit

Permalink
Merge pull request #23 from atlassian-labs/print-error-to-console
Browse files Browse the repository at this point in the history
printing errors to console
  • Loading branch information
alexreardon authored Apr 17, 2020
2 parents da8f90d + 69cba4e commit e7df50b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/task-runner/print-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable no-console */
import { Task } from '../types';

export default function printError({ task, error }: { task: Task; error: any }): void {
if (process.env.NODE_ENV === 'test') {
return;
}
console.group(`🚀❌ Error in task: (${task.name})`);
console.error(error);
console.groupEnd();
}
2 changes: 2 additions & 0 deletions src/task-runner/run-static-task.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ErrorResult, StaticResult, StaticTask } from '../types';
import getErrorResult from './get-error-result';
import printError from './print-error';
import mark from './mark';
import withContainer from './with-container';

Expand All @@ -24,6 +25,7 @@ export async function getResultForStaticTask({
};
return result;
} catch (error) {
printError({ task, error });
return getErrorResult({ task, error });
}
}
2 changes: 2 additions & 0 deletions src/task-runner/run-timed-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ErrorResult, InteractionTask, TimedControls, TimedResult, TimedTask } f
import { asyncMap } from './async';
import getErrorResult from './get-error-result';
import mark from './mark';
import printError from './print-error';
import runInteractionTask from './run-interaction-task';
import withContainer from './with-container';
import withDuration from './with-duration';
Expand Down Expand Up @@ -99,6 +100,7 @@ export async function getResultForTimedTask({
};
return result;
} catch (error) {
printError({ task, error });
return getErrorResult({ task, error });
}
}
3 changes: 2 additions & 1 deletion test/tasks/time-controls.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ it('should only time the portion of the task that is timed', async () => {
},
}),
);
expect((result as TimedResult).averageMs).toBeGreaterThanOrEqual(200);
// not waiting the full 200 as sometimes the engine can come in a little early
expect((result as TimedResult).averageMs).toBeGreaterThanOrEqual(180);
}
{
const result: TimedResult | ErrorResult = await runOneTimed(
Expand Down

0 comments on commit e7df50b

Please sign in to comment.