Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(betterer 🐛): remove printed from api #1233

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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