-
Notifications
You must be signed in to change notification settings - Fork 934
Expand file tree
/
Copy pathroot.test.ts
More file actions
59 lines (48 loc) · 1.51 KB
/
root.test.ts
File metadata and controls
59 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import path from 'path';
import {
spawnScript,
runCLI,
getTempDirectory,
cleanup,
writeFiles,
} from '../jest/helpers';
const DIR = getTempDirectory('test_different_roots');
beforeAll(() => {
// Clean up folder and re-create a new project
cleanup(DIR);
writeFiles(DIR, {});
// Initialise React Native project
runCLI(DIR, ['init', 'TestProject', `--pm`, 'npm', `--install-pods`]);
// Link CLI to the project
const cliPath = path.resolve(__dirname, '../packages/cli');
spawnScript('yarn', ['link'], {
cwd: cliPath,
});
spawnScript('yarn', ['link', '@react-native-community/cli'], {
cwd: path.join(DIR, 'TestProject'),
});
});
afterAll(() => {
cleanup(DIR);
});
test('works when Gradle is run outside of the project hierarchy', async () => {
/**
* Location of Android project
*/
const androidProjectRoot = path.join(DIR, 'TestProject/android');
/*
* Grab absolute path to Gradle wrapper. The fact that we are using
* a wrapper from the project is just a convinience to avoid installing
* Gradle globally
*/
const gradleWrapper = path.join(androidProjectRoot, 'gradlew');
// Make sure that we use `-bin` distribution of Gradle
await spawnScript(gradleWrapper, ['wrapper', '--distribution-type', 'bin'], {
cwd: androidProjectRoot,
});
// Execute `gradle` with `-p` flag and `cwd` outside of project hierarchy
const {stdout} = spawnScript(gradleWrapper, ['-p', androidProjectRoot], {
cwd: '/',
});
expect(stdout).toContain('BUILD SUCCESSFUL');
});