Skip to content

refactor(@schematics/angular): add Karma configuration analyzer and comparer #30833

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clydin
Copy link
Member

@clydin clydin commented Aug 4, 2025

Introduces a new utility for analyzing and comparing Karma configuration files. This is a foundational step for migrating from Karma to other testing frameworks like Jest and Vitest, as it allows the migration schematic to understand the user's existing setup.

The new analyzeKarmaConfig function uses TypeScript's AST parser to safely extract settings from a karma.conf.js file. It can identify common patterns, including require calls, and flags configurations that are too complex for static analysis.

The compareKarmaConfigs function provides the ability to diff a user's Karma configuration against a default template. This will be used to determine which custom settings need to be migrated.

Known limitations of the analyzer:

  • It does not resolve variables or complex expressions. Any value that is not a literal (string, number, boolean, array, object) or a direct require call will be marked as an unsupported value.
  • It does not support Karma configuration files that use ES Modules (import/export syntax).

…omparer

Introduces a new utility for analyzing and comparing Karma configuration files. This is a foundational step for migrating from Karma to other testing frameworks like Jest and Vitest, as it allows the migration schematic to understand the user's existing setup.

The new `analyzeKarmaConfig` function uses TypeScript's AST parser to safely extract settings from a `karma.conf.js` file. It can identify common patterns, including `require` calls, and flags configurations that are too complex for static analysis.

The `compareKarmaConfigs` function provides the ability to diff a user's Karma configuration against a default template. This will be used to determine which custom settings need to be migrated.

Known limitations of the analyzer:
- It does not resolve variables or complex expressions. Any value that is not a literal (string, number, boolean, array, object) or a direct `require` call will be marked as an unsupported value.
- It does not support Karma configuration files that use ES Modules (import/export syntax).
@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 4, 2025
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer area: @schematics/angular target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant