1import { vol } from 'memfs'; 2 3import { startInterfaceAsync } from '../../start/interface/startInterface'; 4import { startBundlerAsync } from '../startBundler'; 5 6jest.mock('../../start/server/DevServerManager', () => ({ 7 DevServerManager: jest.fn(() => ({ 8 startAsync: jest.fn(), 9 getDefaultDevServer: jest.fn(), 10 })), 11})); 12 13jest.mock('../../utils/interactive', () => ({ 14 isInteractive: jest.fn(() => true), 15})); 16 17jest.mock('@expo/config', () => ({ 18 getConfig: jest.fn(() => ({ 19 exp: { 20 platforms: ['ios', 'android'], 21 }, 22 })), 23})); 24 25jest.mock('../../start/interface/startInterface', () => ({ 26 startInterfaceAsync: jest.fn(), 27})); 28 29describe(startBundlerAsync, () => { 30 afterEach(() => vol.reset()); 31 32 it(`starts in headless mode`, async () => { 33 const manager = await startBundlerAsync('/', { 34 headless: true, 35 port: 3000, 36 }); 37 38 expect(manager.startAsync).toHaveBeenCalledWith([ 39 { 40 options: { 41 devClient: true, 42 headless: true, 43 location: {}, 44 port: 3000, 45 }, 46 type: 'metro', 47 }, 48 ]); 49 expect(manager.getDefaultDevServer).toBeCalled(); 50 }); 51 52 it(`starts a server`, async () => { 53 const manager = await startBundlerAsync('/', { 54 headless: false, 55 port: 3000, 56 }); 57 58 expect(manager.startAsync).toHaveBeenCalledWith([ 59 { 60 options: { 61 devClient: true, 62 headless: false, 63 location: {}, 64 port: 3000, 65 }, 66 type: 'metro', 67 }, 68 ]); 69 expect(startInterfaceAsync).toBeCalled(); 70 expect(manager.getDefaultDevServer).not.toBeCalled(); 71 }); 72}); 73