Skip to content

Support for jest-angular-test-verifier when using @angular-devkit/build-angular:jest #25696

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

Open
Neizan93 opened this issue Aug 19, 2023 · 1 comment

Comments

@Neizan93
Copy link

Neizan93 commented Aug 19, 2023

Command

test

Description

As Angular CLI is starting to provide support for Jest in Angular 16, I would like to propose the addition of support for the jest-angular-test-verifier extension or a similar feature. This feature would enable developers to detect files that lack corresponding spec.ts files, helping to ensure comprehensive test coverage in Angular projects.

Benefits

  • Enhance the testing experience in Angular projects by ensuring complete test coverage.
  • Provide a built-in solution for developers to easily identify files without corresponding test files.
  • Reduce the need for external tools or custom scripts to perform this analysis.
  • Align Angular CLI with best practices for maintaining test coverage in Angular applications.

jest-angular-test-verifier npmjs: https://www.npmjs.com/package/jest-angular-test-verifier

Describe the solution you'd like

The proposed solution is to integrate the functionality of jest-angular-test-verifier or a similar tool into Angular CLI. This would involve creating a built-in mechanism that can analyze the project's file structure and identify files that do not have associated spec.ts files. The tool should offer configuration options to customize the file extensions to check, define exclusions, and set exclusion rules based on content.

Describe alternatives you've considered

While the proposed solution suggests integrating jest-angular-test-verifier directly into Angular CLI, an alternative approach could involve developing a dedicated and more sophisticated solution tailored to Angular projects. By leveraging the power and familiarity of Angular's codebase, the CLI team could create an integrated tool that offers more advanced features and optimizations for detecting missing spec.ts files. This approach could lead to a more seamless and tightly integrated experience for Angular developers.

I appreciate your consideration of this feature proposal and look forward to the possibility of seeing this enhancement added to Angular CLI. If you have any questions or need further details, please let me know. Thank you!

@Neizan93 Neizan93 changed the title Support for jest-angular-test-verifier in Angular CLI Support for jest-angular-test-verifier when using @angular-devkit/build-angular:jest Aug 19, 2023
@dgp1130
Copy link
Collaborator

dgp1130 commented Nov 14, 2023

This is an interesting tool and I can definitely see the value of it to the Jest ecosystem. I certainly agree that (almost) every .ts file should have an associated spec.ts file and this isn't trivial to enforce today.

I'm hesitant to add this to Angular projects by default as we typically try to keep our dependencies as minimal as possible. That said, I think it should definitely be possible for applications to add this kind of tool if they choose to. Currently we're experimenting with not exposing the Jest configuration, so this is an interesting use case. I'm curious if there is a way to provide a similar tool without necessarily being coupled to Jest at all?

For example, if this is looking at file paths, could it just check the source file tree for spec.ts files and error for any missing files? That seems like something which could work for Karma and Web Test Runner in addition to Jest and wouldn't rely on a potentially brittle config file integration. Is there a particular reason you went with a Jest integration specifically?

The other thought which comes to mind is whether code coverage could help here. That would contain all the information about which files were tested and you could check that for any files missing a spec.ts file. I'm not sure that's better than just looking at the source tree, but it's one other avenue to consider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants