forked from react-native-community/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.test.ts
62 lines (50 loc) · 1.49 KB
/
root.test.ts
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
60
61
62
import path from 'path';
import {
spawnScript,
runCLI,
getTempDirectory,
cleanupSync,
writeFiles,
} from '../jest/helpers';
const cwd = getTempDirectory('test_different_roots');
beforeAll(() => {
// Register all packages to be linked
for (const pkg of ['platform-ios', 'platform-android']) {
spawnScript('yarn', ['link'], {
cwd: path.join(__dirname, `../packages/${pkg}`),
});
}
// Clean up folder and re-create a new project
cleanupSync(cwd);
writeFiles(cwd, {});
// Initialise React Native project
runCLI(cwd, ['init', 'TestProject']);
// Link CLI to the project
const pkgs = [
'@react-native-community/cli-platform-ios',
'@react-native-community/cli-platform-android',
];
spawnScript('yarn', ['link', ...pkgs], {
cwd: path.join(cwd, 'TestProject'),
});
});
afterAll(() => {
cleanupSync(cwd);
});
test('works when Gradle is run outside of the project hierarchy', () => {
/**
* Location of Android project
*/
const androidProjectRoot = path.join(cwd, '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');
// Execute `gradle` with `-p` flag and `cwd` outside of project hierarchy
const {stdout} = spawnScript(gradleWrapper, ['-p', androidProjectRoot], {
cwd: '/',
});
expect(stdout).toContain('BUILD SUCCESSFUL');
});