23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
|
// Use this to delete a user by their email
|
||
|
// Simply call this with:
|
||
|
// node --require esbuild-register ./cypress/support/delete-user.ts username@example.com
|
||
|
// and that user will get deleted
|
||
|
|
||
|
import { installGlobals } from "@remix-run/node/globals";
|
||
|
import { prisma } from "~/db.server";
|
||
|
|
||
|
installGlobals();
|
||
|
|
||
|
async function deleteUser(email: string) {
|
||
|
if (!email) {
|
||
|
throw new Error("email required for login");
|
||
|
}
|
||
|
if (!email.endsWith("@example.com")) {
|
||
|
throw new Error("All test emails must end in @example.com");
|
||
|
}
|
||
|
|
||
|
await prisma.user.delete({ where: { email } });
|
||
|
}
|
||
|
|
||
|
deleteUser(process.argv[2]);
|