angular-builders: Unable to run Jest tests with custom reporter

Describe the bug Unable to run Jest tests with a custom reporter (https://jestjs.io/docs/en/cli#reporters).

To Reproduce

  1. Run ng test. OK
  2. Run ng test --reporters=default. Failure:
ng test --reporters=default
Schema validation failed with the following errors:
  Data path ".reporters" should be array.
  1. Run ng test --reporters=default --reporters=default. OK

Expected behavior Jest builder should be able to pass single --reporters option to Jest.

Builder:

  • @angular-builders/jest@7.0.0

Libraries

  • @angular-devkit/build-angular@0.10.6

Additional context

Looks like the issue is relevant for some other array options, e.g. --testPathPattern. But the issue is not reproduced for --runTestsByPath, though it doesn’t work with --runTestsByPath either.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 18 (8 by maintainers)

Most upvoted comments

@meltedspark Thanks a lot for the fix!

The fix is on its way, but that won’t be enough for fixing the IDE issue. They are passing the --reporters in a wrong way. The right way to do that is --reporters=default --reporters=jest-junit etc. They don’t use = sign therefore it won’t work even after the issue is fixed here.

Looks like, now tests can be run without = sign too: both ng test --reporters default and ng test --reporters=default work for me with @angular-builders/jest@7.2.1. BTW, I’m a maintainer of Jest test runner in JetBrains IDEs, feel free to ping me regarding IDE-related issues.

@meltedspark JetBrains IDE integration (for Angular projects using Jest runner) passes --reporter. This issue is required for it to be working.