percy / cli

The Percy CLI is used to interact with, and upload snapshots to, percy.io via the command line.
https://docs.percy.io/docs/cli-overview
71 stars 45 forks source link

Percy is not recognizing currency formatting from 1.19.2 onwards #1248

Closed blv-gustavomancuzo closed 1 year ago

blv-gustavomancuzo commented 1 year ago

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

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 commented 1 year ago

Can you share full end to end reproducible example?

blv-gustavomancuzo commented 1 year ago

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[bot] commented 1 year ago

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.

shahidk8 commented 1 year ago

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