Skip to content

Commit

Permalink
fix(betterer 🐛): remove printed from api
Browse files Browse the repository at this point in the history
  • Loading branch information
phenomnomnominal committed Nov 8, 2024
1 parent df77035 commit a1a1e10
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion goldens/api/betterer.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ export class BettererResolverTest<DeserialisedType = unknown, SerialisedType = D

// @public
export interface BettererResult {
printed: string;
value: unknown;
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@
"vitest": "^2.0.5",
"vitest-monocart-coverage": "^2.1.2"
}
}
}
6 changes: 0 additions & 6 deletions packages/betterer/src/results/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ export interface BettererResult {
* @remarks could be anything, including `null`!
*/
value: unknown;
/**
* The printed value of the result.
*
* @remarks may not exist if the test is _new_, and _failed_ or _skipped_!
*/
printed: string;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/betterer/src/run/worker-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ export class BettererWorkerRunΩ implements BettererRun, BettererTestConfig {
private _serialise(deserialised: BettererResult): BettererResultΩ | null {
try {
const { config } = getGlobals();
const deserialisedΩ = deserialised as BettererResultΩ;
return new BettererResultΩ(
this.serialiser.serialise.call(this, deserialised.value, config.resultsPath),
deserialised.printed
this.serialiser.serialise.call(this, deserialisedΩ.value, config.resultsPath),
deserialisedΩ.printed
);
} catch {
return null;
Expand Down
12 changes: 8 additions & 4 deletions packages/betterer/src/suite/suite-summary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BettererFilePaths } from '../fs/index.js';
import type { BettererResultsSerialised } from '../results/index.js';
import type { BettererResultsSerialised, BettererResultΩ } from '../results/index.js';
import type { BettererRuns, BettererRunSummaries } from '../run/index.js';
import type { BettererTestNames } from '../test/index.js';
import type { BettererSuiteSummary } from './types.js';
Expand Down Expand Up @@ -93,7 +93,9 @@ export class BettererSuiteSummaryΩ implements BettererSuiteSummary {
const { result, expected } = runSummary;
invariantΔ(result, 'Test is not _new_, _failed_, or _skipped_ so it must have a result!');
invariantΔ(expected, 'Test is not _new_ so it must have an expected result!');
return result.printed !== expected.printed;
const resultΩ = result as BettererResultΩ;
const expectedΩ = expected as BettererResultΩ;
return resultΩ.printed !== expectedΩ.printed;
});
const newRuns = notFailedOrSkippedOrObsolete.filter((runSummary) => runSummary.isNew && !runSummary.isComplete);
const newOrChangedRunNames = [...changedRuns, ...newRuns].map((runSummary) => runSummary.name);
Expand All @@ -110,11 +112,13 @@ export class BettererSuiteSummaryΩ implements BettererSuiteSummary {
const { expected, name, result } = runSummary;
if ((isSkippedOrFailed && !isNew) || (isWorse && !isUpdated) || isObsolete) {
invariantΔ(expected, 'Test has successfully run in the past so it must have an expected result!');
results[name] = { value: expected.printed };
const expectedΩ = expected as BettererResultΩ;
results[name] = { value: expectedΩ.printed };
return results;
}
invariantΔ(result, 'Test has successfully run so it must have a new result!');
results[name] = { value: result.printed };
const resultΩ = result as BettererResultΩ;
results[name] = { value: resultΩ.printed };
return results;
}, {});
}
Expand Down

0 comments on commit a1a1e10

Please sign in to comment.