Skip to content

Commit 5d17211

Browse files
committed
fix: put summary in <Static>
Fixes #9
1 parent 63e11d6 commit 5d17211

File tree

1 file changed

+48
-35
lines changed

1 file changed

+48
-35
lines changed

src/Reporter.tsx

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,43 @@ const FailureMessage: React.FC<{
8989
const CompletedTests: React.FC<{
9090
completedTests: State['completedTests'];
9191
globalConfig: Config.GlobalConfig;
92-
}> = ({ completedTests, globalConfig }) => {
92+
summary: React.ReactElement;
93+
PostMessage: () => React.ReactElement;
94+
done: boolean;
95+
}> = ({ completedTests, globalConfig, summary, PostMessage, done }) => {
9396
if (completedTests.length === 0) {
9497
return null;
9598
}
9699
const didUpdate = globalConfig.updateSnapshot === 'all';
97100

101+
let testOutputs = completedTests.map(({ testResult, config }) => (
102+
<React.Fragment key={testResult.testFilePath + config.name}>
103+
<ResultHeader config={config} testResult={testResult} />
104+
<VerboseTestList testResult={testResult} globalConfig={globalConfig} />
105+
<TestConsoleOutput
106+
console={testResult.console}
107+
verbose={globalConfig.verbose}
108+
cwd={config.cwd}
109+
/>
110+
<FailureMessage failureMessage={testResult.failureMessage} />
111+
<SnapshotStatus snapshot={testResult.snapshot} afterUpdate={didUpdate} />
112+
</React.Fragment>
113+
));
114+
115+
if (done) {
116+
testOutputs = testOutputs.concat(
117+
<Box paddingTop={1} key="summary">
118+
{summary}
119+
</Box>,
120+
<React.Fragment key="postmessage">
121+
<PostMessage />
122+
</React.Fragment>,
123+
);
124+
}
125+
98126
return (
99127
<Box paddingBottom={1} flexDirection="column">
100-
<Static items={completedTests}>
101-
{({ testResult, config }) => (
102-
<React.Fragment key={testResult.testFilePath + config.name}>
103-
<ResultHeader config={config} testResult={testResult} />
104-
<VerboseTestList
105-
testResult={testResult}
106-
globalConfig={globalConfig}
107-
/>
108-
<TestConsoleOutput
109-
console={testResult.console}
110-
verbose={globalConfig.verbose}
111-
cwd={config.cwd}
112-
/>
113-
<FailureMessage failureMessage={testResult.failureMessage} />
114-
<SnapshotStatus
115-
snapshot={testResult.snapshot}
116-
afterUpdate={didUpdate}
117-
/>
118-
</React.Fragment>
119-
)}
120-
</Static>
128+
<Static items={testOutputs}>{ele => ele}</Static>
121129
</Box>
122130
);
123131
};
@@ -242,29 +250,34 @@ const Reporter: React.FC<Props> = ({
242250
const { exit } = useApp();
243251
React.useEffect(() => {
244252
if (done) {
245-
exit();
253+
setImmediate(exit);
246254
}
247255
}, [done, exit]);
248256

257+
const summary = (
258+
<Summary
259+
aggregatedResults={aggregatedResults}
260+
options={{ estimatedTime, roundTime: true, width }}
261+
done={done}
262+
/>
263+
);
249264
return (
250265
<Box flexDirection="column">
251266
<CompletedTests
252267
completedTests={completedTests}
253268
globalConfig={globalConfig}
254-
/>
255-
<RunningTests tests={currentTests} width={width} />
256-
<Summary
257-
aggregatedResults={aggregatedResults}
258-
options={{ estimatedTime, roundTime: true, width }}
269+
summary={summary}
259270
done={done}
271+
PostMessage={() => (
272+
<PostMessage
273+
aggregatedResults={aggregatedResults}
274+
globalConfig={globalConfig}
275+
contexts={contexts}
276+
/>
277+
)}
260278
/>
261-
{done ? (
262-
<PostMessage
263-
aggregatedResults={aggregatedResults}
264-
globalConfig={globalConfig}
265-
contexts={contexts}
266-
/>
267-
) : null}
279+
<RunningTests tests={currentTests} width={width} />
280+
{done ? null : summary}
268281
</Box>
269282
);
270283
};

0 commit comments

Comments
 (0)