Skip to content

Commit aec0078

Browse files
clydinalan-agius4
authored andcommitted
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.
1 parent 2616ef0 commit aec0078

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed
Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,38 @@
1-
import {join} from 'path';
2-
import {ng} from '../../../utils/process';
3-
import {expectFileToExist} from '../../../utils/fs';
1+
import { join } from 'path';
2+
import { ng } from '../../../utils/process';
3+
import { expectFileToExist, rimraf } from '../../../utils/fs';
44

5-
6-
export default function() {
5+
export default async function () {
76
const upperDirs = join('non', 'existing', 'dir');
87
const rootDir = join('src', 'app', upperDirs);
98

10-
const componentDir = join(rootDir, 'test-component');
11-
const componentTwoDir = join(rootDir, 'test-component-two');
9+
const componentDirectory = join(rootDir, 'test-component');
10+
const componentTwoDirectory = join(rootDir, 'test-component-two');
11+
12+
try {
13+
// Generate a component
14+
await ng('generate', 'component', `${upperDirs}/test-component`)
15+
16+
// Ensure component is created in the correct location relative to the workspace root
17+
await expectFileToExist(join(componentDirectory, 'test-component.component.ts'));
18+
await expectFileToExist(join(componentDirectory, 'test-component.component.spec.ts'));
19+
await expectFileToExist(join(componentDirectory, 'test-component.component.html'));
20+
await expectFileToExist(join(componentDirectory, 'test-component.component.css'));
21+
22+
// Generate another component
23+
await ng('generate', 'component', `${upperDirs}/Test-Component-Two`);
1224

13-
return ng('generate', 'component', `${upperDirs}/test-component`)
14-
.then(() => expectFileToExist(componentDir))
15-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
16-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
17-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.html')))
18-
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
19-
.then(() => ng('generate', 'component', `${upperDirs}/Test-Component-Two`))
20-
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.ts')))
21-
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.spec.ts')))
22-
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.html')))
23-
.then(() => expectFileToExist(join(componentTwoDir, 'test-component-two.component.css')))
25+
// Ensure component is created in the correct location relative to the workspace root
26+
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.ts'));
27+
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.spec.ts'));
28+
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.html'));
29+
await expectFileToExist(join(componentTwoDirectory, 'test-component-two.component.css'));
2430

25-
// Try to run the unit tests.
26-
.then(() => ng('test', '--watch=false'));
31+
// Ensure unit test execute and pass
32+
await ng('test', '--watch=false');
33+
} finally {
34+
// Windows CI may fail to clean up the created directory
35+
// Resolves: "Error: Running "cmd.exe /c git clean -df" returned error code 1"
36+
await rimraf(rootDir);
37+
}
2738
}

0 commit comments

Comments
 (0)