fix(core): add cleanup on e2e tests (#12093)

This commit is contained in:
Miroslav Jonaš 2022-09-19 21:13:17 +02:00 committed by GitHub
parent 27d654a08d
commit 635b2a61a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import { import {
cleanupProject,
createNonNxProjectDirectory, createNonNxProjectDirectory,
getPackageManagerCommand, getPackageManagerCommand,
getSelectedPackageManager, getSelectedPackageManager,
@ -13,6 +14,8 @@ describe('nx init', () => {
packageManager: getSelectedPackageManager(), packageManager: getSelectedPackageManager(),
}).runUninstalledPackage; }).runUninstalledPackage;
afterEach(() => cleanupProject());
it('should work', () => { it('should work', () => {
createNonNxProjectDirectory(); createNonNxProjectDirectory();
updateFile( updateFile(

View File

@ -8,9 +8,8 @@ import {
} from '@nrwl/e2e/utils'; } from '@nrwl/e2e/utils';
describe('project graph creation', () => { describe('project graph creation', () => {
let proj;
beforeEach(() => newProject()); beforeEach(() => newProject());
afterEach(() => cleanupProject()); afterEach(() => cleanupProject());
it('should correctly build the nxdeps.json containing files for the project', () => { it('should correctly build the nxdeps.json containing files for the project', () => {

View File

@ -19,6 +19,8 @@ describe('Nx Commands', () => {
let proj: string; let proj: string;
beforeAll(() => (proj = newProject())); beforeAll(() => (proj = newProject()));
afterAll(() => cleanupProject());
describe('report and list', () => { describe('report and list', () => {
it(`should report package versions`, async () => { it(`should report package versions`, async () => {
const reportOutput = runCLI('report'); const reportOutput = runCLI('report');
@ -79,6 +81,7 @@ describe('Nx Commands', () => {
); );
}, 120000); }, 120000);
}); });
describe('format', () => { describe('format', () => {
const myapp = uniq('myapp'); const myapp = uniq('myapp');
const mylib = uniq('mylib'); const mylib = uniq('mylib');
@ -88,8 +91,6 @@ describe('Nx Commands', () => {
runCLI(`generate @nrwl/js:lib ${mylib}`); runCLI(`generate @nrwl/js:lib ${mylib}`);
}); });
afterAll(() => cleanupProject());
beforeEach(() => { beforeEach(() => {
updateFile( updateFile(
`apps/${myapp}/src/main.ts`, `apps/${myapp}/src/main.ts`,

View File

@ -14,7 +14,7 @@ import {
describe('cache', () => { describe('cache', () => {
beforeEach(() => newProject()); beforeEach(() => newProject());
afterAll(() => cleanupProject()); afterEach(() => cleanupProject());
it('should cache command execution', async () => { it('should cache command execution', async () => {
const myapp1 = uniq('myapp1'); const myapp1 = uniq('myapp1');

View File

@ -5,11 +5,14 @@ import {
runCLI, runCLI,
uniq, uniq,
runCreatePlugin, runCreatePlugin,
cleanupProject,
} from '@nrwl/e2e/utils'; } from '@nrwl/e2e/utils';
describe('create-nx-plugin', () => { describe('create-nx-plugin', () => {
const packageManager = getSelectedPackageManager() || 'pnpm'; const packageManager = getSelectedPackageManager() || 'pnpm';
afterEach(() => cleanupProject());
it('should be able to create a plugin repo and run plugin e2e', () => { it('should be able to create a plugin repo and run plugin e2e', () => {
const wsName = uniq('ws-plugin'); const wsName = uniq('ws-plugin');
const pluginName = uniq('plugin'); const pluginName = uniq('plugin');

View File

@ -1,6 +1,7 @@
import { import {
checkFilesDoNotExist, checkFilesDoNotExist,
checkFilesExist, checkFilesExist,
cleanupProject,
e2eCwd, e2eCwd,
expectNoAngularDevkit, expectNoAngularDevkit,
expectNoTsJestInJestConfig, expectNoTsJestInJestConfig,
@ -20,6 +21,8 @@ import { execSync } from 'child_process';
describe('create-nx-workspace', () => { describe('create-nx-workspace', () => {
const packageManager = getSelectedPackageManager() || 'pnpm'; const packageManager = getSelectedPackageManager() || 'pnpm';
afterEach(() => cleanupProject());
it('should be able to create an empty workspace built for apps', () => { it('should be able to create an empty workspace built for apps', () => {
const wsName = uniq('apps'); const wsName = uniq('apps');
runCreateWorkspace(wsName, { runCreateWorkspace(wsName, {