Home / Function/ tests() — drizzle-orm Function Reference

tests() — drizzle-orm Function Reference

Architecture documentation for the tests() function in mysql-common.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  e9ea1e58_4116_09ab_4725_c9e3a74adeb7["tests()"]
  bcd266b2_f6a8_0abb_2a24_40a68c6f8cc5["mysql-common.ts"]
  e9ea1e58_4116_09ab_4725_c9e3a74adeb7 -->|defined in| bcd266b2_f6a8_0abb_2a24_40a68c6f8cc5
  style e9ea1e58_4116_09ab_4725_c9e3a74adeb7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

integration-tests/tests/mysql/mysql-common.ts lines 288–5480

export function tests(driver?: string) {
	describe('common', () => {
		// afterAll(async () => {
		// 	await mysqlContainer?.stop().catch(console.error);
		// });

		beforeEach(async (ctx) => {
			const { db } = ctx.mysql;
			await db.execute(sql`drop table if exists userstest`);
			await db.execute(sql`drop table if exists users2`);
			await db.execute(sql`drop table if exists cities`);
			await db.execute(sql`drop table if exists \`all_types\``);

			if (driver !== 'planetscale') {
				await db.execute(sql`drop schema if exists \`mySchema\``);
				await db.execute(sql`create schema if not exists \`mySchema\``);
			}

			await db.execute(
				sql`
					create table userstest (
						id serial primary key,
						name text not null,
						verified boolean not null default false,
						jsonb json,
						created_at timestamp not null default now()
					)
				`,
			);

			await db.execute(
				sql`
					create table users2 (
						id serial primary key,
						name text not null,
						city_id int references cities(id)
					)
				`,
			);

			await db.execute(
				sql`
					create table cities (
						id serial primary key,
						name text not null
					)
				`,
			);

			if (driver !== 'planetscale') {
				// mySchema
				await db.execute(
					sql`
						create table \`mySchema\`.\`userstest\` (
							\`id\` serial primary key,
							\`name\` text not null,
							\`verified\` boolean not null default false,
							\`jsonb\` json,
							\`created_at\` timestamp not null default now()
						)
					`,
				);

				await db.execute(
					sql`
						create table \`mySchema\`.\`cities\` (
							\`id\` serial primary key,
							\`name\` text not null
						)
					`,
				);

				await db.execute(
					sql`
						create table \`mySchema\`.\`users2\` (
							\`id\` serial primary key,
							\`name\` text not null,
							\`city_id\` int references \`mySchema\`.\`cities\`(\`id\`)
						)
					`,
				);

Domain

Subdomains

Frequently Asked Questions

What does tests() do?
tests() is a function in the drizzle-orm codebase, defined in integration-tests/tests/mysql/mysql-common.ts.
Where is tests() defined?
tests() is defined in integration-tests/tests/mysql/mysql-common.ts at line 288.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free