fix(testing): add cleanup on cypress e2e tests (#12089)

This commit is contained in:
Miroslav Jonaš 2022-09-19 21:22:07 +02:00 committed by GitHub
parent f84f2819f6
commit 96be1f55fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import {
checkFilesDoNotExist,
cleanupProject,
createFile,
newProject,
runCLI,
@ -144,6 +145,8 @@ import {CommonModule} from '@angular/common';
});
});
afterAll(() => cleanupProject());
it('should test app', () => {
runCLI(
`generate @nrwl/angular:cypress-component-configuration --project=${appName} --generate-tests --no-interactive`

View File

@ -1,5 +1,6 @@
import {
checkFilesExist,
cleanupProject,
createFile,
killPorts,
newProject,
@ -12,9 +13,13 @@ import {
describe('Cypress E2E Test runner', () => {
const myapp = uniq('myapp');
beforeAll(() => {
newProject();
});
afterAll(() => cleanupProject());
it('should generate an app with the Cypress as e2e test runner', () => {
runCLI(
`generate @nrwl/react:app ${myapp} --e2eTestRunner=cypress --linter=eslint`

View File

@ -6,6 +6,7 @@ import {
uniq,
updateFile,
expectJestTestsToPass,
cleanupProject,
} from '@nrwl/e2e/utils';
describe('Jest', () => {
@ -13,6 +14,8 @@ describe('Jest', () => {
newProject({ name: uniq('proj-jest') });
});
afterAll(() => cleanupProject());
it('should be able test projects using jest', async () => {
await expectJestTestsToPass('@nrwl/workspace:lib');
await expectJestTestsToPass('@nrwl/js:lib');
@ -50,10 +53,10 @@ describe('Jest', () => {
stripIndents`
const { registerTsProject } = require('nx/src/utils/register');
const cleanup = registerTsProject('.', 'tsconfig.base.json');
import {setup} from '@global-fun/globals';
import {setup} from '@global-fun/globals';
export default async function() {setup();}
cleanup();
`
);
@ -63,8 +66,8 @@ describe('Jest', () => {
stripIndents`
import { registerTsProject } from 'nx/src/utils/register';
const cleanup = registerTsProject('.', 'tsconfig.base.json');
import {teardown} from '@global-fun/globals';
import {teardown} from '@global-fun/globals';
export default async function() {teardown();}
cleanup();
`

View File

@ -1,4 +1,5 @@
import {
cleanupProject,
createFile,
newProject,
runCLI,
@ -12,6 +13,7 @@ describe('React Cypress Component Tests', () => {
const appName = uniq('cy-react-app');
const usedInAppLibName = uniq('cy-react-lib');
const buildableLibName = uniq('cy-react-buildable-lib');
beforeAll(() => {
projectName = newProject({ name: uniq('cy-react') });
runCLI(`generate @nrwl/react:app ${appName} --no-interactive`);
@ -96,8 +98,8 @@ export interface InputProps {
}
export function Input(props: InputProps) {
return (
<label className="text-green-500">Email:
return (
<label className="text-green-500">Email:
<input className="border-blue-500" type="email" readOnly={props.readOnly}/>
</label>
);
@ -117,6 +119,8 @@ export default Input;
});
});
afterAll(() => cleanupProject());
it('should test app', () => {
runCLI(
`generate @nrwl/react:cypress-component-configuration --project=${appName} --generate-tests`