Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Fix "describe is not defined" error using shared test.ts file

Problem

CodeGen End2End tests were failing with ReferenceError: describe is not defined when running Karma tests for generated Angular applications. The test bootstrap file (test.ts) was missing from 128 template directories.

Solution ✨

Instead of duplicating test.ts 128 times, created 2 shared files in common-files directories that are automatically included in all Angular templates via base template classes.

Changes Made

  • Understand current template system and file copying mechanism
  • Revert the 128 duplicate test.ts files
  • Create shared common files directories
  • Add single test.ts file to each shared location
  • Modify all base template classes to include shared files
  • Fix path resolution to correctly locate common-files
  • Run code review - PASSED (no comments)
  • Run security scan - PASSED (no issues)

File Structure

packages/cli/templates/angular/common-files/src/test.ts
packages/igx-templates/common-files/src/test.ts

Modified Template Classes

  1. AngularTemplate - for ig-ts component templates
  2. IgniteUIForAngularTemplate - for igx-ts/igx-ts-legacy component templates
  3. BaseIgxProject (igx-ts) - for igx-ts project templates
  4. BaseIgxProject (igx-ts-legacy) - for igx-ts-legacy project templates

How It Works

  • Base classes prepend common-files path to templatePaths
  • processTemplates() copies common files first, then template-specific files
  • Templates inherit common files automatically
  • Template-specific files can override common files if needed

Impact

126 duplicate files removed (kept 2 in empty project templates)
~75KB repository size reduction
Single source of truth - update once, affect all templates
Cleaner architecture - follows DRY principle and template inheritance
No breaking changes - empty projects still work with their own test.ts

Testing

All Angular templates (ig-ts, igx-ts, igx-ts-legacy) will now include test.ts when generated, preventing the "describe is not defined" error in CodeGen End2End tests.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Angular]: describe is not defined</issue_title>
<issue_description>This error is thrown for some apps when running CodeGen End2End tests: describe is not defined.
Example of failed build for the [WIP] Apex Charts application: https://github.com/IgniteUI/CodeGen/actions/runs/21631501214/job/62394791842</issue_description>

Comments on the Issue (you are @copilot in this section)

  • Fixes IgniteUI/CodeGen#2196

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 3, 2026 20:42
Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix describe is not defined error in CodeGen tests Add missing test.ts to Angular templates causing "describe is not defined" error Feb 3, 2026
Copilot AI requested a review from Hristo313 February 3, 2026 20:45
Copilot AI and others added 3 commits February 4, 2026 07:15
Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
@Hristo313 Hristo313 closed this Feb 4, 2026
Copilot stopped work on behalf of Hristo313 due to an error February 4, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants