Skip to content

Commit f7090de

Browse files
Broccohansl
authored andcommitted
test(@angular/cli): Test generate from child dir
1 parent 1ec8cb3 commit f7090de

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {join} from 'path';
2+
import {ng} from '../../../utils/process';
3+
import {createDir, expectFileToExist} from '../../../utils/fs';
4+
5+
6+
export default function() {
7+
const subDir = 'sub-dir';
8+
const componentDir = join('src', 'app', subDir, 'test-component');
9+
10+
return Promise.resolve()
11+
// .then(() => process.chdir('src/app'))
12+
.then(() => process.chdir('src'))
13+
.then(() => process.chdir('app'))
14+
.then(() => createDir(subDir))
15+
.then(() => process.chdir(subDir))
16+
.then(() => console.log('curent dir: ' + process.cwd()))
17+
.then(() => ng('generate', 'component', 'test-component'))
18+
.then(() => process.chdir('../../..'))
19+
.then(() => expectFileToExist(componentDir))
20+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.ts')))
21+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.spec.ts')))
22+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.html')))
23+
.then(() => expectFileToExist(join(componentDir, 'test-component.component.css')))
24+
25+
// Try to run the unit tests.
26+
.then(() => ng('test', '--single-run'));
27+
}

tests/e2e/utils/process.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ export function execAndWaitForOutputToMatch(cmd: string, args: string[], match:
169169

170170
let npmInstalledEject = false;
171171
export function ng(...args: string[]) {
172+
process.env.PWD = process.cwd();
173+
172174
const argv = getGlobalVariable('argv');
173175
const maybeSilentNg = argv['nosilent'] ? noSilentNg : silentNg;
174176
if (['build', 'serve', 'test', 'e2e', 'xi18n'].indexOf(args[0]) != -1) {

0 commit comments

Comments
 (0)