Skip to content

fix(jest): suppress warning when jest config is provided inline in angular.json (fixes #1102)#2213

Open
just-jeb wants to merge 2 commits into
masterfrom
fix/1102-no-warning-with-inline-config
Open

fix(jest): suppress warning when jest config is provided inline in angular.json (fixes #1102)#2213
just-jeb wants to merge 2 commits into
masterfrom
fix/1102-no-warning-with-inline-config

Conversation

@just-jeb
Copy link
Copy Markdown
Owner

@just-jeb just-jeb commented May 7, 2026

PR Checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Projects that don't set config in angular.json rely on the schema default jest.config.js. When that file isn't present (because the user keeps their config in package.json, at workspace level, or as an inline JestConfig object), the builder logs warning: unable to locate custom jest configuration file at path … on every run. That's the default-discovery path — absence is normal, not user error. See #1102 (melroy89 2025-05-25 confirms it still fires on package.json-embedded configs).

Issue Number: #1102

What is the new behavior?

The warning fires only when the configured path is not the schema default. config: "jest.config.js" (the default) absent → silent. config: "my-custom-jest.config.ts" absent → still warns, because the user explicitly pointed at a file.

Inline-object and inline-JSON-string configs are unchanged — they already short-circuit before the file-existence check (master, since #7bfe3123).

New unit test: should NOT warn when the schema default jest.config.js is absent.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

The warning text was advisory only; suppressing it for the default-discovery case doesn't change config resolution. Users who relied on the warning to detect a typo'd path still get it.

Other information

Branch was force-pushed to drop unrelated noise (commitlint downgrade, CHANGELOG entry removals, yarn.lock churn).

@just-jeb just-jeb added bug Something isn't working builders:jest documentation labels May 11, 2026
Copy link
Copy Markdown
Owner Author

@just-jeb just-jeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to double check that it actually fixes the related issue and addresses the comments.

Comment thread package.json Outdated
"singleQuote": true
},
"packageManager": "yarn@3.8.7"
"packageManager": "yarn@4.14.1+sha512.64df448055b2d37ba269d7db535a469b8da93f8ef1140c25fd7a83c00a8fbaacb214ca0e02553b92a2c54cef78bb67d0b4817fab02001df0e24fac0faccc3b42"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear why this change is here. Unrelated.

@just-jeb
Copy link
Copy Markdown
Owner Author

Status update on Jeb's review

Addressing "Need to double check that it actually fixes the related issue and addresses the comments"

The package.json inline comment ("Unclear why this change is here. Unrelated.") is now marked as outdated — the unrelated change was removed in a subsequent commit. The current diff contains only:

  1. custom-config.resolver.ts — makes resolveForProject accept undefined/null, returning {} without logging any warning
  2. custom-config.resolver.spec.ts — adds two test cases confirming no warning is logged for undefined and null config inputs
  3. schema.json — changes the config field default from 'jest.config.js' to null, so the builder can distinguish "no config provided" from "explicit file path"

Does this fix issue #1102? Yes — the latest commenter's complaint was "Yet I still get the warning... And no option to disable the warning." With null as the schema default, users who don't specify a config path in angular.json get null → the resolver returns {} silently → no warning. Users who specify an explicit (wrong) path still get the warning, which is intentional.

Is it breaking? No. The change only affects users who previously relied on the implicit jest.config.js lookup. In that case, Jest itself still discovers jest.config.js through its own normal config discovery — the builder just no longer pre-loads it. Net behavior for end users is the same; the warning is gone.

PR is ready for merge.

@just-jeb
Copy link
Copy Markdown
Owner Author

Correction to previous comment — I was wrong about Jest config discovery.

When the builder passes config via argv.push('--config', JSON.stringify(configuration)) (see packages/jest/src/index.ts line 61), Jest receives an explicit --config argument and does not perform its own file discovery. Passing any value to --config disables Jest's default config file lookup entirely.

Actual behavioral change:

  • Users who specify "config": "jest.config.js" or "config": {...} in angular.jsonnot affected
  • Users who have jest.config.js and do not specify config in angular.json (relying on the old schema default) → their jest.config.js will no longer be auto-loaded

The PR primarily fixes the spurious warning for users who provide no config file at all (inline angular.json config or purely builder-defaults). The narrow group affected by the behavioral change needs to add "config": "jest.config.js" to their angular.json options.

Recommendation: Add a note to the PR description documenting this migration path, but the breaking-change label seems unnecessary given the narrow impact and simple migration.

…fault (fixes #1102)

The warning 'unable to locate custom jest configuration file' was firing for
projects that don't configure 'config' in angular.json. That's the default-discovery
case — the user is allowed to keep their config in package.json, at workspace level,
or as an inline JestConfig object. Only warn when the user explicitly pointed at
a missing file.
@just-jeb just-jeb force-pushed the fix/1102-no-warning-with-inline-config branch from 4caecf9 to 4c9f64a Compare May 17, 2026 12:38
…json

Adds a behavioral integration test that exercises the fix for #1102:
when the 'config' option is an inline object (not a file path), tests
must run and pass without the builder crashing or emitting the spurious
"Custom Jest Config not found: [object Object]" warning.

- Adds 'test-inline-config' architect target to examples/jest/simple-app
  using an inline Jest config object ({ testTimeout: 10000, verbose: true })
- Adds 'test:inline-config' script to example package.json
- Adds 'config-inline-object' integration test entry to integration.js,
  using validate.js with --expect-suites=2 --expect-tests=4 to assert
  that all 4 tests in 2 suites actually run and pass
- Extends validate.js with --run-script= to allow running any yarn
  script (not just 'test') while still validating Jest output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant