Angular CLI: 6.0.5
Node: 8.9.4
OS: win32 x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
angular-devkit/architect 0.6.5
angular-devkit/build-angular 0.6.5
angular-devkit/build-optimizer 0.6.5
angular-devkit/core 0.6.5
angular-devkit/schematics 0.6.5
angular/cli 6.0.5
ngtools/webpack 6.0.5
schematics/angular 0.6.5
schematics/update 0.6.5
rxjs 6.2.0
typescript 2.7.2
webpack 4.8.3
ng e2e --specs=foo.spec.ts
Fails with:
Schema validation failed with the following errors:
Data path ".specs" should be array.
@gawicks ----specs option is not available with ng e2e command in angular CLI 6.
Please find below option that are available in Angular CLI 6
ng e2e -h
usage: ng e2e
options:
--base-url
Base URL for protractor to connect to.
--configuration (-c)
Specify the configuration to use.
--dev-server-target
Dev server target to run tests against.
--element-explorer
Start Protractor's Element Explorer for debugging.
--host
Host to listen on.
--port
The port to use to serve the application.
--prod
Flag to set configuration to "prod".
--protractor-config
The name of the Protractor configuration file.
--suite
Override suite in the protractor config.
--webdriver-update
Try to update webdriver.
@ajaypbarokar Do you have any knowledge of why this was removed? Surely such a breaking change should be documented.
So.. it looks like the option is still there . But it isn't documented (?) . The validation error is because we're expecting --specs=foo.spec.ts to be parsed into an array. Due to the way the yargsparser is configured , it works only when passing multiple arguments. i.e.: --specs=foo.spec.ts --specs=bar.spec.ts
A quick fix is to change this line
to
const rawOptions = yargsParser(args, { alias: { help: ['h'] }, boolean: ['help'], array: ['specs'] });
But this looks somewhat ugly to me. Anybody got a better idea?
yes I'm running into the same issue any solution @gawicks ? @ajaypbarokar ?
@twaraich I'm using protractor --specs . Bypassing ng e2e for the moment.
@ajaypbarokar
ng e2e --configuration --dev-server-target=dev
Unexpected end of file.
Error: Unexpected end of file.
at _token (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:60:19)
at _readObject (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:426:13)
at _readValue (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:564:22)
at parseJsonAst (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:605:17)
at Object.parseJson (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:631:12)
at MapSubscriber._host.read.pipe.operators_1.map.str [as project] (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/workspace/workspace.js:178:154)
at MapSubscriber._next (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/rxjs/internal/operators/map.js:86:35)
at MapSubscriber.Subscriber.next (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:103:18)
at MapSubscriber._next (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/rxjs/internal/operators/map.js:92:26)
at MapSubscriber.Subscriber.next (/projects/cff-ui-new/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:103:18)
It is not a new thread here but you find this one when you google "angular 6 e2e --specs" ;-)
The angular 6 way of running a single e2e test is:
suites: {
'exampleTest': './src/example-test.e2e-spec.ts',
}
Best regards
As @dabruns has shown (great solution anyway), i have made a sample with cucumber that use the same approach as suites, but it create the object dynamically with the function (and then the --suite parameter works again without having to put every suite at config):
// npm i --save-dev globule
function getSuites() {
const fileSufix = ".feature";
const globulePathsArray = require(`globule`).find([ `${process.cwd()}/e2e/src/features/**/*${fileSufix}` ]);
const suites = { };
globulePathsArray.forEach(pathFile => {
const filename = require("path").basename(pathFile);
const filenameWithoutSufix = filename.replace(fileSufix, '');
suites[filenameWithoutSufix] = pathFile;
});
return suites;
}
More details could be seen here: https://github.com/jvitor83/angularcli-cucumber/blob/master/README.md
To work with the jasmine (default), it should be _(not tested)_:
// npm i --save-dev globule
exports.config = {
...
suites: getSuites(),
}
function getSuites() {
const fileSufix = ".e2e-spec.ts";
const globulePathsArray = require(`globule`).find([ `${process.cwd()}/e2e/src/**/*${fileSufix}` ]);
const suites = { };
globulePathsArray.forEach(pathFile => {
const filename = require("path").basename(pathFile);
const filenameWithoutSufix = filename.replace(fileSufix, '');
suites[filenameWithoutSufix] = pathFile;
});
return suites;
}
The getSuites() function above only works on the default project. If you have multiple projects in your workspace, replace the globulePathsArray declaration with:
const globulePathsArray = require(`globule`).find([ require('path').join(__dirname, `./src/**/*${fileSufix}`) ]);
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
It is not a new thread here but you find this one when you google "angular 6 e2e --specs" ;-)
The angular 6 way of running a single e2e test is:
ng e2e --suite=exampleTest
Best regards