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(
22    `require('../../build/src/run/android').expoRunAndroid`
23  );
24  expect(modules).toStrictEqual([
25    '../node_modules/ansi-styles/index.js',
26    '../node_modules/arg/index.js',
27    '../node_modules/chalk/source/index.js',
28    '../node_modules/chalk/source/util.js',
29    '../node_modules/has-flag/index.js',
30    '../node_modules/supports-color/index.js',
31    '@expo/cli/build/src/log.js',
32    '@expo/cli/build/src/run/android/index.js',
33    '@expo/cli/build/src/utils/args.js',
34    '@expo/cli/build/src/utils/errors.js',
35  ]);
36});
37
38it('runs `npx expo run:android --help`', async () => {
39  const results = await execute('run:android', '--help');
40  expect(results.stdout).toMatchInlineSnapshot(`
41    "
42      Description
43        Run the native Android app locally
44
45      Usage
46        $ npx expo run:android <dir>
47
48      Options
49        --no-build-cache       Clear the native build cache
50        --no-install           Skip installing dependencies
51        --no-bundler           Skip starting the bundler
52        --variant <name>       Build variant. Default: debug
53        -d, --device [device]  Device name to run the app on
54        -p, --port <port>      Port to start the dev server on. Default: 8081
55        -h, --help             Output usage information
56    "
57  `);
58});
59