ci: fix component-path-case E2E test on Windows CI

Windows CI is failing when trying to use the common test cleanup routine for the `generate/component/component-path-case` E2E test. This fix manually removes the newly created directory within the test.
This commit is contained in:
Charles Lyding 2021-03-18 11:23:18 -04:00 committed by Alan Agius
parent 2616ef0d3f
commit aec0078404

View File

@ -1,27 +1,38 @@
import {join} from 'path';
import {ng} from '../../../utils/process';
import {expectFileToExist} from '../../../utils/fs';
import { join } from 'path';
import { ng } from '../../../utils/process';
import { expectFileToExist, rimraf } from '../../../utils/fs';
export default function() {
export default async function () {
const upperDirs = join('non', 'existing', 'dir');
const rootDir = join('src', 'app', upperDirs);
const componentDir = join(rootDir, 'test-component');
const componentTwoDir = join(rootDir, 'test-component-two');
const componentDirectory = join(rootDir, 'test-component');
const componentTwoDirectory = join(rootDir, 'test-component-two');
return ng('generate', 'component', `${upperDirs}/test-component`)
.then(() => expectFileToExist(componentDir))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.html')))
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
.then(() => ng('generate', 'component', `${upperDirs}/Test-Component-Two`))
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.ts')))
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.spec.ts')))
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.html')))
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.css')))
try {
// Generate a component
await ng('generate', 'component', `${upperDirs}/test-component`)
// Try to run the unit tests.
.then(() => ng('test', '--watch=false'));
// Ensure component is created in the correct location relative to the workspace root
await expectFileToExist(join(componentDirectory, 'test-component.component.ts'));
await expectFileToExist(join(componentDirectory, 'test-component.component.spec.ts'));
await expectFileToExist(join(componentDirectory, 'test-component.component.html'));
await expectFileToExist(join(componentDirectory, 'test-component.component.css'));
// Generate another component
await ng('generate', 'component', `${upperDirs}/Test-Component-Two`);
// Ensure component is created in the correct location relative to the workspace root
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.ts'));
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.spec.ts'));
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.html'));
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.css'));
// Ensure unit test execute and pass
await ng('test', '--watch=false');
} finally {
// Windows CI may fail to clean up the created directory
// Resolves: "Error: Running "cmd.exe /c git clean -df" returned error code 1"
await rimraf(rootDir);
}
}