Initial Commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from "@suaveplan/testing/runner";
|
||||
import { createPwaObservability } from "./observability";
|
||||
import type { PwaObservability } from "./observability.types";
|
||||
|
||||
describe("createPwaObservability", () => {
|
||||
it("emits on every documented counter and histogram", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const obs = createPwaObservability();
|
||||
const counters = [
|
||||
obs.counters.swInstalledTotal,
|
||||
obs.counters.swActivatedTotal,
|
||||
obs.counters.swUpdatedTotal,
|
||||
obs.counters.syncEnqueuedTotal,
|
||||
obs.counters.syncProcessedTotal,
|
||||
obs.counters.syncFailedTotal,
|
||||
obs.counters.pushSubscribedTotal,
|
||||
obs.counters.installPromptTotal,
|
||||
];
|
||||
for (const c of counters) {
|
||||
expect(() => c.add(1, { tenant: "acme" })).not.toThrow();
|
||||
}
|
||||
expect(() =>
|
||||
obs.histograms.syncFlushMs.record(12.3, { kind: "ok" })
|
||||
).not.toThrow();
|
||||
expect(() =>
|
||||
obs.histograms.cacheStrategyMs.record(4.2, {
|
||||
strategy: "cacheFirst",
|
||||
})
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("passes through a pre-built observability bundle", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const existing = createPwaObservability();
|
||||
const passed: PwaObservability = createPwaObservability({
|
||||
observability: existing,
|
||||
});
|
||||
expect(passed).toBe(existing);
|
||||
});
|
||||
|
||||
it("supplies a default meter and tracer when none are provided", {
|
||||
timeout: 5000,
|
||||
}, () => {
|
||||
const obs = createPwaObservability();
|
||||
expect(obs.meter).toBeDefined();
|
||||
expect(obs.tracer).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user