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]: Warning Multiple pipes match the name date while using a date + translate pipe in a component for the unit tests #1960

Open
remi-amadeus opened this issue Jul 10, 2024 · 2 comments
Labels
bug Something isn't working priority:medium

Comments

@remi-amadeus
Copy link

Package name

localization

Package version

10.2.16

Reproduction steps

Create a component and use both the date and the translate pipes in the template of this component
Implement the UT file for this component with the proper imports, providers and declaration
Write whatever test and try to run it

NOTE:
we are using jest on which we have added https://www.npmjs.com/package/jest-fail-on-console in the setup-jest.ts. This will make the UT fails as soon as something is logged in the console.

Current result

image

A warning is raised, and due to the use of jest-fail-on-console then the tests are failing. We could deactivate it (or ignore for console.warn) but we would rather not.

Expected result

No multiple date pipe warning.

Additional comments

This seems coming from the use of mockTranslationModules (

export function mockTranslationModules(
) which imports the LocalizationModule (https://github.com/AmadeusITGroup/otter/blob/9b7c439f0d4c098f18919d1264dff7d7db88cb66/packages/%40o3r/localization/src/tools/localization.module.ts) and the LocalizationModule is overriding the DatePipe.
image

@remi-amadeus remi-amadeus added bug Something isn't working triage labels Jul 10, 2024
@matthieu-crouzet
Copy link
Contributor

Hello @remi-amadeus, could you please provide a reproduction spec file please ?
From what I understand we provide an override of the DatePipe, so it should not be provided twice.

@remi-amadeus
Copy link
Author

remi-amadeus commented Jul 24, 2024

Hi @matthieu-crouzet ,

Thank you for your reply.

To reproduce, you can simply replace the template of app.component.html in the showcase app:
https://github.com/AmadeusITGroup/otter/blob/main/apps/showcase/src/app/app.component.html

with

<div>{{ myDate | date: 'short' }}</div>
<div>{{ 'test' | translate }}</div>

It would show the warnings:
image
image

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants