1/* eslint-env jest */
2import fs from 'fs/promises';
3
4import { execute, getLoadedModulesAsync, projectRoot } from './utils';
5
6const originalForceColor = process.env.FORCE_COLOR;
7const originalCI = process.env.CI;
8
9beforeAll(async () => {
10  await fs.mkdir(projectRoot, { recursive: true });
11  process.env.FORCE_COLOR = '0';
12  process.env.CI = '1';
13});
14
15afterAll(() => {
16  process.env.FORCE_COLOR = originalForceColor;
17  process.env.CI = originalCI;
18});
19
20it('loads expected modules by default', async () => {
21  const modules = await getLoadedModulesAsync(`require('../../build/src/run/ios').expoRunIos`);
22  expect(modules).toStrictEqual([
23    '../node_modules/ansi-styles/index.js',
24    '../node_modules/arg/index.js',
25    '../node_modules/chalk/source/index.js',
26    '../node_modules/chalk/source/util.js',
27    '../node_modules/has-flag/index.js',
28    '../node_modules/supports-color/index.js',
29    '@expo/cli/build/src/log.js',
30    '@expo/cli/build/src/run/ios/index.js',
31    '@expo/cli/build/src/utils/args.js',
32    '@expo/cli/build/src/utils/errors.js',
33  ]);
34});
35
36it('runs `npx expo run:ios --help`', async () => {
37  const results = await execute('run:ios', '--help');
38  expect(results.stdout).toMatchInlineSnapshot(`
39    "
40      Info
41        Run the iOS app binary locally
42
43      Usage
44        $ npx expo run:ios
45
46      Options
47        --no-build-cache                 Clear the native derived data before building
48        --no-install                     Skip installing dependencies
49        --no-bundler                     Skip starting the Metro bundler
50        --scheme [scheme]                Scheme to build
51        --configuration <configuration>  Xcode configuration to use. Debug or Release. Default: Debug
52        -d, --device [device]            Device name or UDID to build the app on
53        -p, --port <port>                Port to start the Metro bundler on. Default: 8081
54        -h, --help                       Usage info
55
56      Build for production (unsigned) with the Release configuration:
57        $ npx expo run:ios --configuration Release
58    "
59  `);
60});
61