mirror of
https://github.com/expo/react-native-community-cli.git
synced 2026-11-14 19:11:48 -10:00
* chore: make `cleanup` async Using `rimraf.sync` can cause `ENOTEMPTY` and `EBUSY` errors on Windows. This can make the Windows CI to fail randomly. Changing to the async method defaults to autoretry 3 times and thus avoiding this issues. * chore: jest config * chore: e2e tests use sync cleanup * chore: pr feedback * chore: revert timeout * Update __e2e__/default.test.ts * Update __e2e__/default.test.ts Co-authored-by: Michał Pierzchała <[email protected]>
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
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');
|
|
});
|