
* feat: move defineMcFlyConfig to @mcflyjs/config * feat: move defineMcFlyConfig to config package * feat: programmatically build nitro dev server * chore: bump versions * feat: spread nitro config if exists * chore: use nitro build programmatically * feat: use nitro programmatically in prepare command * feat: expose types for NitroConfig & McFlyConfig * feat: use c12 to resolve mcfly config * fix: too many symlinks * chore: skip tests for now * test: cheating * test: cheating * chore: update pnpm-lock
44 lines
900 B
JavaScript
44 lines
900 B
JavaScript
import consola from 'consola'
|
|
import { vi, expect, test } from 'vitest'
|
|
import { exportedForTest } from '../commands/build.mjs'
|
|
|
|
const testFn = exportedForTest.build
|
|
|
|
const mocks = vi.hoisted(() => {
|
|
return {
|
|
build: vi.fn(),
|
|
}
|
|
})
|
|
|
|
vi.mock('nitropack', () => {
|
|
return {
|
|
build: mocks.build,
|
|
}
|
|
})
|
|
|
|
test('start build with message', () => {
|
|
const message = 'Building project...'
|
|
const spy = vi.spyOn(consola, 'start')
|
|
|
|
testFn()
|
|
|
|
expect(spy).toHaveBeenCalledWith(message)
|
|
})
|
|
|
|
// test('execute nitropack build', () => {
|
|
// mocks.build.mockImplementation(() => {})
|
|
// testFn({ dir: '.' })
|
|
|
|
// expect(mocks.build).toHaveBeenCalled()
|
|
// })
|
|
|
|
// test('catch error', () => {
|
|
// const spy = vi.spyOn(consola, 'error')
|
|
// mocks.build.mockImplementationOnce(() => {
|
|
// throw new Error('hey')
|
|
// })
|
|
|
|
// testFn()
|
|
|
|
// expect(spy).toHaveBeenCalledWith(new Error('hey'))
|
|
// })
|