fix: synchronize mounted component props
Quality / quality (ubuntu-latest) (push) Failing after 9m51s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-23 19:42:39 +05:30
parent 56cde5aaf8
commit 53b9947ef9
11 changed files with 159 additions and 10 deletions
+6
View File
@@ -205,3 +205,9 @@ export type {
} from "./advanced.ts";
export { withDatabaseRollback, createFactory, captureBrowserArtifacts } from "./platform.ts";
export type { TransactionalDatabase, BrowserArtifactPage } from "./platform.ts";
export { detectMutations } from "./mutation.ts";
export type {
MutationCase,
MutationReport,
DetectMutationsOptions,
} from "./mutation.ts";
+52
View File
@@ -0,0 +1,52 @@
export interface MutationCase<T> {
name: string;
value: T;
}
export interface MutationReport<O> {
baseline: O;
killed: string[];
survived: string[];
}
export interface DetectMutationsOptions<T, O> {
baseline: T;
mutations: Array<MutationCase<T>>;
exercise(value: T): O | Promise<O>;
equivalent?(left: O, right: O): boolean;
}
/**
* Run the same behavioural probe against a baseline and explicit mutations.
* A mutation survives when the observable result is unchanged. The helper
* throws with every survivor by default, making it suitable for an ordinary
* Bun test and CI without a second runner or source-rewriting process.
*/
export async function detectMutations<T, O>(
options: DetectMutationsOptions<T, O>,
): Promise<MutationReport<O>> {
if (!options.mutations.length) {
throw new Error("WRN-MUTATION-EMPTY: declare at least one meaningful mutation");
}
const equivalent = options.equivalent ?? ((left, right) => Object.is(left, right));
const baseline = await options.exercise(options.baseline);
const killed: string[] = [];
const survived: string[] = [];
for (const mutation of options.mutations) {
if (!mutation.name.trim()) throw new Error("WRN-MUTATION-NAME: every mutation needs a name");
let same = false;
try {
same = equivalent(baseline, await options.exercise(mutation.value));
} catch {
// A behavioural failure is a killed mutation.
}
(same ? survived : killed).push(mutation.name);
}
if (survived.length) {
throw Object.assign(
new Error(`WRN-MUTATION-SURVIVED: ${survived.join(", ")}`),
{ report: { baseline, killed, survived } },
);
}
return { baseline, killed, survived };
}