Repository: directus/directus
File: api/src/cli/index.test.ts (TypeScript)

Code before:
			vi.mocked(startServer).mockClear();

			await program.parseAsync(['node', 'directus', 'start']);

			expect(startServer).toHaveBeenCalledTimes(1);
		});

		test('Should call init when init command is invoked', async () => {
			const init = (await import('./commands/init/index.js')).default;
			vi.mocked(init).mockClear();

			await program.parseAsync(['node', 'directus', 'init']);

			expect(init).toHaveBeenCalledTimes(1);
		});

		test('Should call bootstrap when bootstrap command is invoked', async () => {
			const bootstrap = (await import('./commands/bootstrap/index.js')).default;
			vi.mocked(bootstrap).mockClear();

			await program.parseAsync(['node', 'directus', 'bootstrap']);

			expect(bootstrap).toHaveBeenCalledTimes(1);
		});

		test('Should call dbMigrate with correct arguments', async () => {
			const dbMigrate = (await import('./commands/database/migrate.js')).default;

			vi.mocked(dbMigrate).mockClear();
			await program.parseAsync(['node', 'directus', 'database', 'migrate:latest']);
			expect(dbMigrate).toHaveBeenCalledWith('latest');

			vi.mocked(dbMigrate).mockClear();
			await program.parseAsync(['node', 'directus', 'database', 'migrate:up']);
			expect(dbMigrate).toHaveBeenCalledWith('up');

			vi.mocked(dbMigrate).mockClear();
			await program.parseAsync(['node', 'directus', 'database', 'migrate:down']);
			expect(dbMigrate).toHaveBeenCalledWith('down');
		});
	});

	describe('Command options', () => {
		test('Should parse command options correctly', async () => {
			const bootstrap = (await import('./commands/bootstrap/index.js')).default;
			vi.mocked(bootstrap).mockClear();

			await program.parseAsync(['node', 'directus', 'bootstrap', '--skipAdminInit']);

			expect(bootstrap).toHaveBeenCalledWith(
				expect.objectContaining({

Review comment (suggestion):
Might be worth to use a `test.each` for `latest`,`up`,`down` due to the similarity

Code after:

			expect(program.args).toEqual(['start', 'test']);
		});
	});

	describe('Command actions', () => {
		test('Should call startServer when start command is invoked', async () => {
			await program.parseAsync(['node', 'directus', 'start']);

			expect(startServer).toHaveBeenCalledTimes(1);
		});

		test('Should call init when init command is invoked', async () => {
			await program.parseAsync(['node', 'directus', 'init']);

			expect(init).toHaveBeenCalledTimes(1);
		});

		test('Should call bootstrap when bootstrap command is invoked', async () => {
			await program.parseAsync(['node', 'directus', 'bootstrap']);

			expect(bootstrap).toHaveBeenCalledTimes(1);
		});

		test.each([
			['latest', 'migrate:latest'],
			['up', 'migrate:up'],
			['down', 'migrate:down'],
		])('Should call dbMigrate with "%s" argument', async (expectedArg, command) => {
			await program.parseAsync(['node', 'directus', 'database', command]);

			expect(dbMigrate).toHaveBeenCalledWith(expectedArg);
		});
	});

	describe('Command options', () => {
		test('Should parse command options correctly', async () => {
			await program.parseAsync(['node', 'directus', 'bootstrap', '--skipAdminInit']);

			expect(bootstrap).toHaveBeenCalledWith(
				expect.objectContaining({
					skipAdminInit: true,
				}),
				expect.anything(),
			);
		});

		test('Should parse multiple options for users create command', async () => {
			await program.parseAsync([
				'node',
				'directus',