Skip to content

Commit 636edb8

Browse files
committed
fix: always pass column width
1 parent 73bfbf6 commit 636edb8

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

src/Reporter.tsx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ const TestConsoleOutput = ({
7070
};
7171

7272
const CompletedTests: React.FC<{
73-
completedTests: Array<{
74-
testResult: TestResult;
75-
config: Config.ProjectConfig;
76-
}>;
77-
width?: number;
73+
completedTests: State['completedTests'];
74+
width: number;
7875
globalConfig: Config.GlobalConfig;
7976
}> = ({ completedTests, width, globalConfig }) => {
8077
if (completedTests.length === 0) {
@@ -86,7 +83,7 @@ const CompletedTests: React.FC<{
8683
<Box paddingBottom={1} flexDirection="column">
8784
<Static>
8885
{completedTests.map(({ testResult, config }) => (
89-
<React.Fragment key={testResult.testFilePath}>
86+
<React.Fragment key={testResult.testFilePath + config.name}>
9087
<ResultHeader
9188
config={config || globalConfig}
9289
testResult={testResult}
@@ -176,6 +173,32 @@ const reporterReducer: React.Reducer<State, DateEvents> = (
176173
}
177174
};
178175

176+
const RunningTests: React.FC<{
177+
tests: State['currentTests'];
178+
width: number;
179+
}> = ({ tests, width }) => {
180+
if (tests.length === 0) {
181+
return null;
182+
}
183+
184+
return (
185+
<Box paddingBottom={1} flexDirection="column">
186+
{tests.map(([path, config]) => (
187+
<Box key={path + config.name}>
188+
<Runs />
189+
<DisplayName config={config} />
190+
<FormattedPath
191+
pad={8}
192+
columns={width}
193+
config={config}
194+
testPath={path}
195+
/>
196+
</Box>
197+
))}
198+
</Box>
199+
);
200+
};
201+
179202
const Reporter: React.FC<Props> = ({
180203
register,
181204
globalConfig,
@@ -220,22 +243,7 @@ const Reporter: React.FC<Props> = ({
220243
width={width}
221244
globalConfig={globalConfig}
222245
/>
223-
{currentTests.length > 0 && (
224-
<Box paddingBottom={1} flexDirection="column">
225-
{currentTests.map(([path, config]) => (
226-
<Box key={path + config.name}>
227-
<Runs />
228-
<DisplayName config={config || globalConfig} />
229-
<FormattedPath
230-
pad={8}
231-
columns={width}
232-
config={config || globalConfig}
233-
testPath={path}
234-
/>
235-
</Box>
236-
))}
237-
</Box>
238-
)}
246+
<RunningTests tests={currentTests} width={width} />
239247
<Summary
240248
aggregatedResults={aggregatedResults}
241249
options={{ estimatedTime, roundTime: true, width }}

src/shared.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const TestStatus: React.FC<{ testResult: TestResult }> = ({ testResult }) => {
6969
export const ResultHeader: React.FC<{
7070
testResult: TestResult;
7171
config: Config.ProjectConfig;
72-
width?: number;
72+
width: number;
7373
}> = ({ testResult, config, width }) => (
7474
<Box>
7575
<TestStatus testResult={testResult} />
@@ -92,9 +92,9 @@ export const FormattedPath = ({
9292
pad: number;
9393
config: Config.ProjectConfig | Config.GlobalConfig;
9494
testPath: Config.Path;
95-
columns?: number;
95+
columns: number;
9696
}) => {
97-
const maxLength = (columns || 0) - pad;
97+
const maxLength = columns - pad;
9898
const relative = relativePath(config, testPath);
9999
const { basename } = relative;
100100
let { dirname } = relative;
@@ -147,5 +147,6 @@ export const FormatFullTestPath: React.FC<{
147147
config: Config.GlobalConfig | Config.ProjectConfig;
148148
testPath: Config.Path;
149149
}> = ({ config, testPath }) => (
150-
<FormattedPath config={config} testPath={testPath} pad={0} />
150+
// TODO: maybe not 9000? We just don't want to trim it
151+
<FormattedPath config={config} testPath={testPath} pad={0} columns={9000} />
151152
);

0 commit comments

Comments
 (0)