Skip to content

Commit

Permalink
ci: fix component-path-case E2E test on Windows CI
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit aec0078)
  • Loading branch information
clydin authored and alan-agius4 committed Mar 18, 2021
1 parent fff75bd commit b7a7c6c
Showing 1 changed file with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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');

try {
// Generate a component
await ng('generate', 'component', `${upperDirs}/test-component`)

// 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`);

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')))
// 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'));

// Try to run the unit tests.
.then(() => ng('test', '--watch=false'));
// 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);
}
}

0 comments on commit b7a7c6c

Please sign in to comment.