Home / File/ index.test.ts — drizzle-orm Source File

index.test.ts — drizzle-orm Source File

Architecture documentation for index.test.ts, a typescript file in the drizzle-orm codebase. 4 imports, 0 dependents.

File typescript 4 imports

Entity Profile

Dependency Diagram

graph LR
  a9d17400_7087_672e_a5e2_5d4c5ef4c9e4["index.test.ts"]
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  a9d17400_7087_672e_a5e2_5d4c5ef4c9e4 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  c10a8be4_82f5_0980_d482_1683db51662a["globals"]
  a9d17400_7087_672e_a5e2_5d4c5ef4c9e4 --> c10a8be4_82f5_0980_d482_1683db51662a
  9a46d98d_eb2d_c1e4_a37b_506dd514a6a7["fs"]
  a9d17400_7087_672e_a5e2_5d4c5ef4c9e4 --> 9a46d98d_eb2d_c1e4_a37b_506dd514a6a7
  412eac48_6e13_8b0f_b7b2_5c943c225130["path"]
  a9d17400_7087_672e_a5e2_5d4c5ef4c9e4 --> 412eac48_6e13_8b0f_b7b2_5c943c225130
  style a9d17400_7087_672e_a5e2_5d4c5ef4c9e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { afterAll, expect, it } from 'vitest';
import 'zx/globals';
import * as fs from 'fs';
import path from 'path';

$.verbose = false;

const IMPORTS_FOLDER = 'tests/imports/files';

const folderPath = '../drizzle-orm/dist/package.json';
const pj = JSON.parse(fs.readFileSync(folderPath, 'utf8'));

if (!fs.existsSync(IMPORTS_FOLDER)) {
	fs.mkdirSync(IMPORTS_FOLDER);
}

it('dynamic imports check for CommonJS', async () => {
	const promises: ProcessPromise[] = [];
	for (const [i, key] of Object.keys(pj['exports']).entries()) {
		const o1 = path.join('drizzle-orm', key);
		if (
			o1.startsWith('drizzle-orm/bun-sqlite') || o1.startsWith('drizzle-orm/pglite')
			|| o1.startsWith('drizzle-orm/expo-sqlite') || o1.startsWith('drizzle-orm/libsql/wasm')
			|| o1.startsWith('drizzle-orm/bun-sql')
		) {
			continue;
		}
		fs.writeFileSync(`${IMPORTS_FOLDER}/imports_${i}.cjs`, 'requ');
		fs.appendFileSync(`${IMPORTS_FOLDER}/imports_${i}.cjs`, 'ire("' + o1 + '");\n', {});

		// fs.writeFileSync(`${IMPORTS_FOLDER}/imports_${i}.mjs`, 'imp');
		// fs.appendFileSync(`${IMPORTS_FOLDER}/imports_${i}.mjs`, 'ort "' + o1 + '"\n', {});

		promises.push(
			$`node ${IMPORTS_FOLDER}/imports_${i}.cjs`.nothrow(),
			// $`node ${IMPORTS_FOLDER}/imports_${i}.mjs`.nothrow(),
		);
	}
	const results = await Promise.all(promises);

	for (const result of results) {
		expect(result.exitCode, result.message).toBe(0);
	}
});

it('dynamic imports check for ESM', async () => {
	const promises: ProcessPromise[] = [];
	for (const [i, key] of Object.keys(pj['exports']).entries()) {
		const o1 = path.join('drizzle-orm', key);
		if (
			o1.startsWith('drizzle-orm/bun-sqlite') || o1.startsWith('drizzle-orm/expo-sqlite')
			|| o1.startsWith('drizzle-orm/bun-sql')
		) {
			continue;
		}
		fs.writeFileSync(`${IMPORTS_FOLDER}/imports_${i}.mjs`, 'imp');
		fs.appendFileSync(`${IMPORTS_FOLDER}/imports_${i}.mjs`, 'ort "' + o1 + '"\n', {});
		promises.push(
			$`node ${IMPORTS_FOLDER}/imports_${i}.mjs`.nothrow(),
			$`node --import import-in-the-middle/hook.mjs ${IMPORTS_FOLDER}/imports_${i}.mjs`.nothrow(),
		);
	}

	const results = await Promise.all(promises);

	for (const result of results) {
		expect(result.exitCode, result.message).toBe(0);
	}
});

afterAll(() => {
	fs.rmdirSync(IMPORTS_FOLDER, { recursive: true });
});

Dependencies

  • fs
  • globals
  • path
  • vitest

Frequently Asked Questions

What does index.test.ts do?
index.test.ts is a source file in the drizzle-orm codebase, written in typescript.
What does index.test.ts depend on?
index.test.ts imports 4 module(s): fs, globals, path, vitest.
Where is index.test.ts in the architecture?
index.test.ts is located at integration-tests/tests/imports/index.test.ts (directory: integration-tests/tests/imports).

Analyze Your Own Codebase

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

Try Supermodel Free