question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest: Neither --config nor --configuration works with v14

See original GitHub issue

Describe the Bug

After upgrading to version 14 I can no longer pass in the --configuration argument since it throws an error. The same goes for the --config option.

Also I have noticed, that when running ng test --help it prints for both --config and --configuration flag the abbreviation -c. Maybe this leads to this error.

Minimal Reproduction

Install latest version (v14), configure project and run ng test --configuration=test. It wil exit with an error (exit code 1) and print out the usage info Usage: ng [--config=<pathToConfigFile>] [TestPathPattern]. Also at the very end there is the error argv.config.match is not a function.

Expected Behavior

It should take either the angular configuration or the jest config and not throw an error.

Screenshots

$ ng test --configuration=test
Warning: 'no-cache' option has been declared with a 'no' prefix in the schema.Please file an issue with the author of this package.
Warning: 'noStackTrace' option has been declared with a 'no' prefix in the schema.Please file an issue with the author of this package.
Usage: ng [--config=<pathToConfigFile>] [TestPathPattern]

Options:
  -h, --help                        Show help                          [boolean]
      --version                     Show version number                [boolean]
      --all                         The opposite of `onlyChanged`. If
                                    `onlyChanged` is set by default, running
                                    jest with `--all` will force Jest to run all
                                    tests instead of running only tests related

[...]

                                    test re-run in watch mode. If the test path
                                    matches any of the patterns, it will be
                                    skipped.                             [array]
      --watchman                    Whether to use watchman for file crawling.
                                    Disable using --no-watchman.       [boolean]

Documentation: https://jestjs.io/

argv.config.match is not a function

Environment


Libs
- @angular/core version: 14.0.5
- @angular-devkit/build-angular version: 14.0.5
- @angular-builders/jest version: 14.0.0
- Jest: 28.1.2

For Tooling issues:
- Node version: v16.14.2
- Platform: Mac

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
RTKcommented, Jul 12, 2022

I debugged a bit and found out, that the --config argument gets passed twice to jest:

index.ts in function runJest(options, context) -> buildArgv

[
  '--tsConfig=./src/tsconfig.spec.json',
  '--no-cache',
  '--config=test',
  '--globalMocks=getComputedStyle',
  '--globalMocks=doctype',
  '--globalMocks=styleTransform',
  '--globalMocks=matchMedia',
  '--notifyMode=failure-change',
  '--prettierPath=prettier',
  '--config',
  '{"preset":"jest-preset-angular",[...]}'

--configuration=test gets transformed into --config=test but the builder hardcodes a --config=[builder specific configurations] as well -> argv.push('--config', JSON.stringify(configuration));

Also I realized, that no options from my test Angular configuration gets added to the argv.

1reaction
just-jebcommented, Oct 18, 2022

Should be fixed in 14.0.2-beta.1, please confirm.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't run tests with jest 28.0 · Issue #10117 · nrwl/nx - GitHub
I had to work on setting up my resolver to remove object properties from the parsed package.json so it would target main instead...
Read more >
Configuring Jest
Jest's configuration can be defined in the package.json file of your project, or through a jest.config.js, or jest.config.ts file or through ...
Read more >
How to use ESM tests with jest? - Stack Overflow
Here are the steps I took to run Jest with a test using ESM. The source files under test were also written using...
Read more >
Jest | RubyMine Documentation - JetBrains
Open the Run/Debug Configuration dialog (Run | Edit Configurations on the main menu), click · Specify the Node. · Specify the location of...
Read more >
Configuration | ts-jest - Huafu
ts-jest configuration is done within Jest configuration object. This latest can be in package.json under the jest property, or in its own jest.config.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found