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