skip to Main Content

fellow developers!

I am using VS Code (latest version) for my Angular (17) app.
I can right-click a folder and select the "New component" option to automatically create a new Angular component quickly and easily.

That’s great and it’s working fine. The thing is that it also automatically creates the spec file of the component, and I don’t need that.

Right now, every time I do this, I have to manually delete this extra file.

It’s not that big of an issue of course, but it would be great if this didn’t happen in the first place.

Now, I’m not sure if this feature is built in on VS Code or it’s done with an extension I once installed.

If anyone knows this specific feature and can tell me if I can disable the automatic creation of the new component’s spec file, I would appreciate to know how.

The following screenshot shows a part of the menu that open when I right-click a folder in my app:
(the option I refer to is "New component" and NOT "New Angular Component")

enter image description here

2

Answers


  1. It’s most likely an extension, and you will have to check their documentation on that.

    But if you do want to create the components manually using cli, you can use this to skip the test file generation

    ng generate component hello --skip-tests
    
    Login or Signup to reply.
  2. To create a new component in an Angular project using VS Code without generating a spec file, you can use the Angular CLI (ng generate component) or manually create the necessary files. Here’s how you can do it using the Angular CLI:

    Open a terminal in VS Code.

    Navigate to your Angular project directory using the cd command.

    Run the following command to generate a new component without a spec file:

    ng generate component component-name –skip-tests

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search