Files
react-native-community-cli/__e2e__/install.test.ts
Antón MolledaandMichał Pierzchała 5819a17d14 chore: make cleanup async (#1156)
* 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]>
2020-05-12 15:53:04 +02:00

39 lines
1.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import path from 'path';
import {
runCLI,
getTempDirectory,
cleanupSync,
writeFiles,
} from '../jest/helpers';
const DIR = getTempDirectory('command-install-test');
const pkg = 'react-native-config';
beforeEach(() => {
cleanupSync(DIR);
writeFiles(DIR, {
'node_modules/react-native/package.json': '{}',
'package.json': '{}',
});
});
afterEach(() => cleanupSync(DIR));
test.each(['yarn', 'npm'])('install module with %s', pm => {
if (pm === 'yarn') {
writeFiles(DIR, {'yarn.lock': ''});
}
const {stdout, code} = runCLI(DIR, ['install', pkg]);
expect(stdout).toContain(`Installing "${pkg}"`);
expect(stdout).toContain(`Linking "${pkg}"`);
// TODO – this behavior is a bug, linking should fail/warn without native deps
// to link. Not a high priority since we're changing how link works
expect(stdout).toContain(`Successfully installed and linked "${pkg}"`);
expect(require(path.join(DIR, 'package.json'))).toMatchObject({
dependencies: {
[pkg]: expect.any(String),
},
});
expect(code).toBe(0);
});