mcfly/packages/core/test/build.test.ts
Ayo 08c2497fab feat: use fastify as server
- remove nitropack
- new @mcflyjs/fastify package
- test-core workspace for testing the new setup
2026-05-25 22:43:15 +02:00

47 lines
970 B
TypeScript

import type { ParsedArgs } from 'citty'
import consola from 'consola'
import { expect, it, vi } from 'vitest'
import { exportedForTest } from '../src/commands/build'
const build = exportedForTest.build
const mocks = vi.hoisted(() => {
return {
build: vi.fn(),
}
})
vi.mock('nitropack', () => {
return {
build: mocks.build,
}
})
it('start build with message', () => {
const message = 'Building project...'
const spy = vi.spyOn(consola, 'start')
build({ dir: 'fakeDir', _: [] } as ParsedArgs)
expect(spy).toHaveBeenCalledWith(message)
})
// TODO
it.skip('execute nitropack build', () => {
mocks.build.mockImplementation(() => {})
build({ dir: '.', _: [] })
expect(mocks.build).toHaveBeenCalled()
})
// TODO
it.skip('catch error', () => {
const spy = vi.spyOn(consola, 'error')
mocks.build.mockImplementationOnce(() => {
throw new Error('hey')
})
build({ _: [] })
expect(spy).toHaveBeenCalledWith(new Error('hey'))
})