Skip to content

Commit

Permalink
test: Add e2e tests for generating application and library
Browse files Browse the repository at this point in the history
  • Loading branch information
Brocco authored and filipesilva committed Mar 27, 2018
1 parent ad910fc commit 824bc76
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
11 changes: 11 additions & 0 deletions tests/e2e/tests/generate/application/application-basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {ng} from '../../../utils/process';
import { expectFileToMatch } from '../../../utils/fs';
import { useCIChrome } from '../../../utils/project';


export default function() {
return ng('generate', 'application', 'app2')
.then(() => expectFileToMatch('angular.json', /\"app2\":/))
.then(() => useCIChrome('app2'))
.then(() => ng('test', 'app2', '--watch=false'));
}
13 changes: 13 additions & 0 deletions tests/e2e/tests/generate/library/library-basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {ng} from '../../../utils/process';
import { expectFileToMatch } from '../../../utils/fs';


export default function() {
return ng('generate', 'library', 'my-lib')
.then(() => expectFileToMatch('angular.json', /\"my-lib\":/));

// TODO: enable once generating Angular v6 projects
// this is due to the service using `providedIn`
// .then(() => useCIChrome())
// .then(() => ng('test', 'my-lib', '--watch=false'));
}
6 changes: 3 additions & 3 deletions tests/e2e/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ export function useCIDefaults() {
});
}

export function useCIChrome() {
export function useCIChrome(projectDir = 'test-project') {
// There's a race condition happening in Chrome. Enabling logging in chrome used by
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
// --no-sandbox is needed for Circle CI.
// Travis can use headless chrome, but not appveyor.
return Promise.resolve()
.then(() => replaceInFile('projects/test-project-e2e/protractor.conf.js',
.then(() => replaceInFile(`projects/${projectDir}-e2e/protractor.conf.js`,
`'browserName': 'chrome'`,
`'browserName': 'chrome',
chromeOptions: {
Expand All @@ -192,7 +192,7 @@ export function useCIChrome() {
`))
// Not a problem if the file can't be found.
.catch(() => null)
.then(() => replaceInFile('projects/test-project/karma.conf.js', `browsers: ['Chrome'],`,
.then(() => replaceInFile(`projects/${projectDir}/karma.conf.js`, `browsers: ['Chrome'],`,
`browsers: ['ChromeCI'],
customLaunchers: {
ChromeCI: {
Expand Down

0 comments on commit 824bc76

Please sign in to comment.