Skip to content
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

[BUG] TypeError: this.iconRegistryService.getIcon is not a function in standalone component test #3751

Open
2 of 9 tasks
RasmusKjeldgaard opened this issue Jan 13, 2025 · 1 comment
Labels
bug 👶🏻 New For new issues before prioritisation and refinement NOT Prioritized Issue not yet prioritized and added to a Milestone workaround possible

Comments

@RasmusKjeldgaard
Copy link
Collaborator

Describe the bug

When testing standalone components with jest (possibly also other test frameworks) the icon component is not properly stubbed even though KirbyTestingModule is used.

Describe how to reproduce the bug

The bug can be verified by checking the following reproduction out, installing dependencies with npm install and running npm run test, which gives this result:
image

The module-based component AppComponent successfully runs tests, while the standalone component test suite fails with TypeError: this.iconRegistryService.getIcon is not a function, because the actual icon component implementation is initialized for some reason.

Which Kirby version was used?

v9.7.3 and v10.2.1

What was the expected behavior?

Add any screenshots

Please complete the following information:

  • OS: [e.g. Windows, MacOS, iOS]
  • Browser [e.g. Chrome, Safari]
  • Browser version [e.g. 22]

Are there any additional context?


Checklist:

The following tasks should be carried out in sequence in order to follow the process of contributing correctly.

Verification

To make sure the bug is not intended behaviour; it should be verified by a member of team Kirby before moving on to implementation.

  • Make sure the NOT verified label has been removed by a member of team Kirby; do not proceed until this is done.

Implementation

The contributor who wants to implement this issue should:

Review

Once the issue has been implemented and is ready for review:

@RasmusKjeldgaard RasmusKjeldgaard added bug NOT Prioritized Issue not yet prioritized and added to a Milestone 👶🏻 New For new issues before prioritisation and refinement labels Jan 13, 2025
@github-project-automation github-project-automation bot moved this to 💌 Inbox in Kirby Jan 13, 2025
@RasmusKjeldgaard RasmusKjeldgaard changed the title [BUG] TypeError: this.iconRegistryService.getIcon is not a function in jest tests [BUG] TypeError: this.iconRegistryService.getIcon is not a function in standalone component test Jan 14, 2025
@RasmusKjeldgaard
Copy link
Collaborator Author

Current workaround is to provide a stubbed out version yourself when setting up the test: { provide: IconRegistryService, useValue: { getIcon: () => ({ name: '' }) } }

@alxzak alxzak assigned alxzak and unassigned alxzak Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 👶🏻 New For new issues before prioritisation and refinement NOT Prioritized Issue not yet prioritized and added to a Milestone workaround possible
Projects
Status: 💌 Inbox
Development

No branches or pull requests

2 participants