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

Percy is not recognizing currency formatting from 1.19.2 onwards #1248

Closed
blv-gustavomancuzo opened this issue May 3, 2023 · 4 comments
Closed
Labels
🐛 bug Something isn't working

Comments

@blv-gustavomancuzo
Copy link

blv-gustavomancuzo commented May 3, 2023

The problem

It seems like Percy is not being able to handle currency formatting correctly from 1.19.2 onwards, the issue is still occurring in 1.24.0.

Screenshots from Percy build:

Before 1.19.2:
Captura de pantalla 2023-05-03 a la(s) 11 11 19

After 1.19.2:
Captura de pantalla 2023-05-03 a la(s) 11 11 27

Environment

  • Node version: 16.17
  • @percy/cli version: 1.19.2 (still happening in 1.24.0)
  • Version of Percy SDK you’re using: N/A
  • OS version: MacOS Ventura 13.3
  • Type of shell command-line [interface]: bash

Details

We are currently using @percy/cypress with the cy.percySnapshot command for our visual tests.

Code to reproduce issue

Method responsible for formatting the currency:

export const formatCurrency = (
  value: number | string = 0,
  currency: Currency = CURRENCIES.COP.VALUE
) => {
  const currencyFormatOptions = {
    currency,
    style: 'currency'
  }

  const parsedValue = parseFloat(value.toString())

  if (isNaN(parsedValue)) throw 'Value must be a valid number'

  const currencyValue = parsedValue.toLocaleString(
    CURRENCIES[currency].LOCALE,
    currencyFormatOptions
  )

  const regex = /([\d,.]+)/
  const unit = currencyValue.replace(regex, '')
  const amount = currencyValue.match(regex)?.[0]
  const amountPosition = currencyValue.match(regex)?.index

  return {
    currencyValue,
    splitCurrency: {
      ...(!amountPosition && { amount }),
      unit,
      ...(amountPosition && { amount })
    }
  }
@samarsault
Copy link
Contributor

Can you share full end to end reproducible example?

@blv-gustavomancuzo
Copy link
Author

blv-gustavomancuzo commented May 9, 2023

Hey @samarsault, sure 😃

You can use this repo to reproduce the issue. On the README file you have the instructions on how to do it.

@github-actions
Copy link

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the 🍞 stale Closed due to inactivity label May 23, 2023
@itsjwala itsjwala added 🐛 bug Something isn't working and removed 🍞 stale Closed due to inactivity labels May 29, 2023
@shahidk8
Copy link
Contributor

shahidk8 commented Jul 4, 2023

The issue is fixed in versions 1.24.2 onwards. Please update to latest release of percy/cli.

@shahidk8 shahidk8 closed this as completed Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants