1import { vol } from 'memfs'; 2 3import { getWebOutputPath, readConfigJson } from '../Config'; 4 5jest.mock('fs'); 6 7describe('getWebOutputPath', () => { 8 beforeAll(() => { 9 const packageJson = JSON.stringify( 10 { 11 name: 'testing123', 12 version: '0.1.0', 13 main: 'index.js', 14 }, 15 null, 16 2 17 ); 18 19 const appJson = { 20 name: 'testing 123', 21 version: '0.1.0', 22 slug: 'testing-123', 23 sdkVersion: '100.0.0', 24 }; 25 26 vol.fromJSON({ 27 '/standard/package.json': JSON.stringify(packageJson), 28 '/standard/app.json': JSON.stringify({ expo: appJson }), 29 '/custom/package.json': JSON.stringify(packageJson), 30 '/custom/app.json': JSON.stringify({ 31 expo: { ...appJson, web: { build: { output: 'defined-in-config' } } }, 32 }), 33 }); 34 }); 35 afterAll(() => vol.reset()); 36 37 it('uses the default output build path for web', () => { 38 const { exp } = readConfigJson('/standard'); 39 const outputPath = getWebOutputPath(exp); 40 expect(outputPath).toBe('web-build'); 41 }); 42 43 it('uses a custom output build path from the config', () => { 44 const { exp } = readConfigJson('/custom'); 45 const outputPath = getWebOutputPath(exp); 46 expect(outputPath).toBe('defined-in-config'); 47 }); 48 49 beforeEach(() => { 50 delete process.env.WEBPACK_BUILD_OUTPUT_PATH; 51 }); 52 it('uses an env variable for the web build path', () => { 53 process.env.WEBPACK_BUILD_OUTPUT_PATH = 'custom-env-path'; 54 55 for (const project of ['/custom', '/standard']) { 56 const { exp } = readConfigJson(project); 57 const outputPath = getWebOutputPath(exp); 58 expect(outputPath).toBe('custom-env-path'); 59 } 60 }); 61}); 62