70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
29 lines
900 B
TypeScript
29 lines
900 B
TypeScript
import { existsSync } from "node:fs";
|
|
// eslint-disable-next-line no-restricted-imports -- We need to import `expect` from "vitest" so that we can extend it
|
|
import { expect } from "vitest";
|
|
|
|
declare module "vitest" {
|
|
interface CustomMatchers<R = unknown> {
|
|
toExist(): R;
|
|
}
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- required by vitest's module augmentation pattern
|
|
interface Assertion<T> extends CustomMatchers<T> {}
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- required by vitest's module augmentation pattern
|
|
interface AsymmetricMatchersContaining extends CustomMatchers {}
|
|
}
|
|
|
|
expect.extend({
|
|
toExist: (received) => {
|
|
const exists = existsSync(received);
|
|
|
|
if (!exists) {
|
|
return {
|
|
message: () => `expected ${received} to exist on disk.`,
|
|
pass: false,
|
|
};
|
|
}
|
|
|
|
return { pass: true, message: () => "passed." };
|
|
},
|
|
});
|