import execa from 'execa' import run from '../../src/run' import getCommand from '../../src/commands' import NuxtCommand from '../../src/command' jest.mock('execa') jest.mock('../../src/commands') jest.mock('../../src/command') describe('run', () => { beforeEach(() => { jest.resetAllMocks() getCommand.mockImplementation(cmd => cmd === 'dev' ? ({ name: 'dev', run: jest.fn() }) : undefined) }) afterAll(() => { jest.clearAllMocks() }) test('nuxt aliases to nuxt dev', async () => { await run([]) expect(getCommand).toHaveBeenCalledWith('dev') expect(NuxtCommand.run).toHaveBeenCalledWith(expect.anything(), [], {}) }) test('nuxt --foo aliases to nuxt dev --foo', async () => { await run(['--foo']) expect(getCommand).toHaveBeenCalledWith('dev') expect(NuxtCommand.run).toHaveBeenCalledWith(expect.anything(), ['--foo'], {}) }) test('all hooks passed to NuxtCommand', async () => { const hooks = { foo: jest.fn() } await run([], hooks) expect(NuxtCommand.run).toHaveBeenCalledWith(expect.anything(), [], hooks) }) test('nuxt