Skip to content

Commit

Permalink
changed summary to only animate when updating
Browse files Browse the repository at this point in the history
When in watch mode, the summary background used to animate all
the time. This meant that it was difficult to understand if the test was
currently running or if the results you were looking at were the result
of the latest test run.

With this change the background only animates when a test is actually
in progress. If you are in watch mode, the play button turns to a stop
button and the background is not animated, But when Jest is running,
the background is animating. When jest finishes, the background stops.

This addresses issue Raathigesh#193
  • Loading branch information
Greg Veres committed May 15, 2020
1 parent 2296cf6 commit 2abc1e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ui/test-file/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ function TestFile({ selectedFilePath, isRunning, projectRoot, onStop }: Props) {
result => result.changeToResult
);

const isUpdating = isRunning && (result === null ||(result.numPassingTests === 0 && result.numFailingTests === 0));

const haveSnapshotFailures = ((result && result.testResults) || []).some(
testResult => {
return (testResult.failureMessages || []).some(failureMessage =>
Expand All @@ -115,8 +117,8 @@ function TestFile({ selectedFilePath, isRunning, projectRoot, onStop }: Props) {
failingTests={result && result.numFailingTests}
path={selectedFilePath}
isRunning={isRunning}
isUpdating={isUpdating}
isLoadingResult={loading}
haveSnapshotFailures={haveSnapshotFailures}
onRun={() => {
runFile();
}}
Expand Down
8 changes: 4 additions & 4 deletions ui/test-file/summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ interface Props {
passingTests: number;
failingTests: number;
isRunning: boolean;
isUpdating: boolean;
isLoadingResult: boolean;
onRun: () => void;
onStop: () => void;
onSnapshotUpdate: () => void;
haveSnapshotFailures: boolean;
}

export default function FileSummary({
Expand All @@ -123,11 +123,11 @@ export default function FileSummary({
passingTests,
failingTests,
isRunning,
isUpdating,
isLoadingResult,
onRun,
onStop,
onSnapshotUpdate,
haveSnapshotFailures
onSnapshotUpdate
}: Props) {
const Icon = isRunning ? StopCircle : Play;

Expand All @@ -139,7 +139,7 @@ export default function FileSummary({

return (
<Container p={4} bg="slightDark">
{(isRunning || isLoadingResult) && <ContainerBG />}
{( isUpdating || isLoadingResult) && <ContainerBG />}
<RightContainer>
<FilePath fontSize={15} mb={3}>
{path.replace(projectRoot, "")}
Expand Down

0 comments on commit 2abc1e0

Please sign in to comment.