t3-code-android-nightly/.repos/effect-smol/packages/tools/api-diff/test/Error.test.ts
2026-09-07 21:54:44 -07:00

25 lines
1.1 KiB
TypeScript

import { ApiDiffError, isApiDiffError } from "@effect/api-diff/Error"
import { isSnapshotExtractionError, SnapshotExtractionError } from "@effect/api-diff/Snapshot"
import { assert, describe, it } from "@effect/vitest"
import { vi } from "vitest"
import type * as ApiDiffErrorModule from "../src/Error.ts"
import type * as SnapshotModule from "../src/Snapshot.ts"
describe("tagged errors", () => {
it("recognizes errors from a reloaded module copy", async () => {
vi.resetModules()
const ForeignApiDiffError = await vi.importActual<typeof ApiDiffErrorModule>("../src/Error.ts")
const ForeignSnapshot = await vi.importActual<typeof SnapshotModule>("../src/Snapshot.ts")
const apiDiffError = new ForeignApiDiffError.ApiDiffError({ message: "boom" })
assert.isFalse(apiDiffError instanceof ApiDiffError)
assert.isTrue(isApiDiffError(apiDiffError))
const snapshotError = new ForeignSnapshot.SnapshotExtractionError({
message: "boom",
diagnostics: []
})
assert.isFalse(snapshotError instanceof SnapshotExtractionError)
assert.isTrue(isSnapshotExtractionError(snapshotError))
})
})