-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(new): add e2e test for
ng new
command
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {deleteFile, deleteDir} from '../../utils/fs'; | ||
import * as path from 'path'; | ||
import {ng, git} from '../../utils/process'; | ||
import {gitCommit} from '../../utils/git'; | ||
|
||
export default function() { | ||
const parentTestprojectDir = process.cwd(); | ||
const projectName = 'new-test-project'; | ||
|
||
return Promise.resolve() | ||
// The test setup already creates a project, lets' clean that before running `ng new` | ||
.then(() => removeSetupProject(parentTestprojectDir)) | ||
|
||
// Run `ng new` | ||
.then(() => ng('new', projectName)) | ||
.then(() => process.chdir(path.join(parentTestprojectDir, projectName))) | ||
|
||
// Try to run the unit tests. | ||
.then(() => ng('test', '--single-run')) | ||
|
||
// Run post-test steps whether test passes or fails | ||
.then(prepareGitForTestCleanup, prepareGitForTestCleanup); | ||
} | ||
|
||
// Change the project inherited from Setup into normal | ||
// non angular-cli project folder, so we can call `ng new` | ||
function removeSetupProject (parentTestprojectDir: string) { | ||
return Promise.resolve() | ||
|
||
// Change the project inherited from Setup into normal | ||
// non angular-cli project folder, so we can call `ng new` | ||
.then(() => process.chdir(parentTestprojectDir)) | ||
.then(() => deleteDir('.git')) | ||
.then(() => deleteFile('angular-cli.json')) | ||
.then(() => deleteFile('package.json')); | ||
} | ||
|
||
// The post-test cleanup breaks if it doesn't have a git repository with a branch and a commit | ||
function prepareGitForTestCleanup() { | ||
return Promise.resolve() | ||
.then(() => git('config', 'user.email', 'angular-core+e2e@google.com')) | ||
.then(() => git('config', 'user.name', 'Angular CLI E2e')) | ||
.then(() => git('config', 'commit.gpgSign', 'false')) | ||
.then(() => gitCommit('ng-new test')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters