Skip to content

Enable developers to select a unit testing framework #23734

@mgechev

Description

@mgechev

🚀 Feature request

Allow developers to select a unit testing framework similarly to ng e2e.

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Description

Over the past few years we stopped shipping a linter by default and in v12 we enabled a plugin-based selection of an e2e testing framework similarly to ng deploy. At the same time, we've been getting lots of requests for Jest in the CLI and even mocha. The different tools have their trade-offs and even though karma allows real browser testing it's often outperformed by jest.

Describe the solution you'd like

Meet developers where they are and enable them to use the unit testing framework they want. Remove karma by default and instead change ng test to output a list of available and supported options, such as karma and jest.

Similarly to ng e2e and ng deploy we can recommend solutions which have high adoption and are maintained by the owner of the testing tool to provide guarantees for higher reliability.

A challenge with this approach is that it gets harder to automatically generate a unit test for every generated component/directive/component/pipe. We'd like to enable testing vendors to plug into the corresponding generator so they can provide a template that we can use in ng generate to produce a dummy unit test.

That's the open question as of right now, which will unblock us to provide flexibility while continuing to enforce best practices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions