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