2

The expected behavior when creating a new component using angular-cli is that angular.json.projects is updated with an entry describing the newly created component. The observed behavior is that angular-cli does not do so.

I found this out after running ng test newComponent and receiving the message Project 'inline' does not support the 'test' target.

The ng test newComponent worked after I updated angular.json.projects to describe the newly created component.

I'm migrating an Angular 2 component library to the new Angular 7 Workspace model. I'm building it from scratch using Todd Palmer's The Angular Library Series - Creating a Library with Angular CLI recipe.

Although the recipe does not recommend testing a newly created component, I did and observed the failure herein described.

Steps to reproduce

ng new workspace --create-application=false
  • Create a library
ng generate library library --prefix=abc
  • Create a testing application, I call it a living style guide
ng generate application living-style-guide
  • Create a new library component
ng generate component newComponent —project=library
  • Validate the component creation
ng test newComponent —project=library

Observed Behavior The last command fails with the following message

Project 'newComponent' does not support the 'test' target.
Error: Project 'newComponent' does not support the 'test' target.
    at TestCommand.initialize (./node_modules/@angular/cli/models/architect-command.js:53:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Expected Behavior angular-cli updates angular.json projects object with a description of newly created library components and their unit tests pass.

1 Answer 1

0

Discussed this with Alan Agius, from angular-cli. Alan explained to me that ng test <target> is designed to work only for projects, not library components; he suggested I follow their issue #3603.

I closed my last email to Alan by reminding him that a developer who has a library with a lot of components, is developing a new component, and wishes to target the component in development for testing, should be able to do it with a simple ng command.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.