wrangler and have it run commands/import files for youwrangler dev in remote mode against your live DBunstable_dev() API to set up everything for testing.persistTo) then read the migrations files and execute them via better-sliqte3?
env.DB.prepare() at the start of the file for 10 will it incur a performance penalty/go to the actual DB?D1PreparedStatement objectpersistTo to like test will place the db into test/v3/d1/{uuid} where uuid is the id of the database in the .toml file. Not sure how should I access that in the testcreateTestDatabase(): Promise<D1Database>runMigration(db: D1Database, name: string, dir?: string): Promise<void>deleteTestDatabase(db: D1Database): Promise<void>D1Database allows you to call the regular .prepare, .exec, etc methods on top..state is stored.runMigration and it mirrors wrangler d1 migrations apply <name> -> that gives you the tools you need to run a series of migrations from within CIwrangler d1 migrations apply run in CI's without like logging into cloudflare? because i might just run it as a shell command as of now to make my test setup less brittle and later swithc to the programatic runMigration API once its outmigrations apply defaults to remote.Options:
--local Execute commands/files against a local DB for use with wrangler dev --local [boolean]
--preview Execute commands/files against a preview D1 DB [boolean] [default: false]
--persist-to Specify directory to use for local persistence (you must use --local with this flag) [string]
--experimental-backend Use new experimental DB backend [boolean] [default: false]
--batch-size Number of queries to send in a single batch [number] [default: 10000]describe("backend json rest api", () => {
const testId = randomUUID();
let worker;
before(async () => {
// running migrations on db
execSync(
`export NO_D1_WARNING=true && wrangler d1 migrations apply db --local --persist-to=temp/${testId}`
);
// setting up worker
worker = await unstable_dev("src/index.ts", {
experimental: {
disableExperimentalWarning: true,
},
persistTo: `temp/${testId}`,
});
});
after(async () => {
await worker.stop();
execSync("rm -rf temp");
});
// ... tests here
});wranglerunstable_dev()describe("backend json rest api", () => {
let worker;
before(async () => {
worker = await unstable_dev("src/index.ts", {
experimental: { disableExperimentalWarning: true },
});
});
after(async () => {
await worker.stop();
});
// ... actual tests here
});env.DB.prepare()