Skip to content

feat(test): Add --config-file flag option to ng test command #1102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/angular-cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const NgCliTestCommand = TestCommand.extend({
{ name: 'log-level', type: String },
{ name: 'port', type: Number },
{ name: 'reporters', type: String },
{ name: 'build', type: Boolean, default: true }
{ name: 'build', type: Boolean, default: true },
{ name: 'config', type: String, aliases: ['c', 'cf']}
],

run: function(commandOptions: any) {
Expand Down
4 changes: 3 additions & 1 deletion packages/angular-cli/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default Task.extend({
const projectRoot = this.project.root;
return new Promise((resolve) => {
const karma = requireDependency(projectRoot, 'karma');
const karmaConfig = path.join(projectRoot, this.project.ngConfig.config.test.karma.config);
const karmaConfig = (options.config) ?
options.config :
path.join(projectRoot, this.project.ngConfig.config.test.karma.config);

// Convert browsers from a string to an array
if (options.browsers) {
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/tests/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {ng} from '../../utils/process';
import * as path from 'path';


export default function() {
// make sure both --watch=false and --single-run work
const karmaConfigPath = path.join(process.cwd(), './karma.conf.js');

return ng('test', '--single-run')
.then(() => ng('test', '--watch=false'));
.then(() => ng('test', '--watch=false'))
.then(() => ng('test', '--watch=false', `--config=${karmaConfigPath}`));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to have a test for an alternative configuration, not just the default one.

}