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

Passing different config is not detected while running Jest snapshot test #1476

Open
1 of 6 tasks
aymkin opened this issue Dec 11, 2023 · 1 comment
Open
1 of 6 tasks
Labels
bug Something isn't working

Comments

@aymkin
Copy link

aymkin commented Dec 11, 2023

Description

Passing differenct config to the GluestackUIProviders does not result to a proper snapshot

This issue can be related too: #1450

CodeSandbox/Snack link

No response

Steps to reproduce

  1. Install GluestackUI
  2. Eject 'npx gluestack-ui-scripts eject-theme'
  3. In config folder create two files firstBrandColors and secondBrandColors
// firstBrandColors.ts
export const brandColors = {
  primary0: '#d0ffea',
  primary50: '#c2f5db',
  primary100: '#a4ecc7',
  primary200: '#87e1b3',
  primary300: '#6dd39e',
  primary400: '#4fcb8b',
  primary500: '#44bd7e',
  primary600: '#44a673',
  primary700: '#438f68',
  primary800: '#41795c',
  primary900: '#3e6551',
  primary950: '#2f5541',

  secondary0: '#ffffff',
  secondary50: '#f5f8ff',
  secondary100: '#e6eaf7',
  secondary200: '#cad3eb',
  secondary300: '#b0bcdc',
  secondary400: '#95a5d0',
  secondary500: '#8a99c4',
  secondary600: '#808eb6',
  secondary700: '#7884a7',
  secondary800: '#717b96',
  secondary900: '#6d7382',
  secondary950: '#5d6473',
}
// secondBrandColors.ts
export const brandColors = {
  primary0: '#fceacf',
  primary50: '#ffd99f',
  primary100: '#ffc977',
  primary200: '#ffb950',
  primary300: '#ffa928',
  primary400: '#ff9900',
  primary500: '#e18907',
  primary600: '#c37a0c',
  primary700: '#a86b11',
  primary800: '#8e5d13',
  primary900: '#754e15',
  primary950: '#4d3006',

  secondary0: '#b8fcfc',
  secondary50: '#6cffff',
  secondary100: '#44ffff',
  secondary200: '#1dffff',
  secondary300: '#00f4f4',
  secondary400: '#00cccc',
  secondary500: '#05afaf',
  secondary600: '#099494',
  secondary700: '#0c7979',
  secondary800: '#0d6161',
  secondary900: '#0d4949',
  secondary950: '#043636',
}
  1. in config folder create another file configs.ts
import { brandColors as firstSetPrimaryAndSecondaryColors } from './firstBrandColors'
import { brandColors as secondSetPrimaryAndSecondaryColors } from './secondBrandColors'
import { config } from './gluestack-ui.config'

export const firstConfigs = {
  ...config,
  tokens: {
    colors: {
      ...firstSetPrimaryAndSecondaryColors,
    },
  },
}

export const secondConfig = {
  ...config,
  tokens: {
    colors: {
      ...secondSetPrimaryAndSecondaryColors,
    },
  },
}
  1. Create TextSamples.test.tsx
import { GluestackUIProvider, Text } from '@gluestack-ui/themed'
import React from 'react'
import renderer from 'react-test-renderer'

import { firstConfigs, secondConfig } from './configs'

const renderWithTheme = (component: React.JSX.Element) => {
  return renderer.create(
    <React.Fragment>
      <GluestackUIProvider config={firstConfigs}>{component}</GluestackUIProvider>
      <GluestackUIProvider config={secondConfig}>{component}</GluestackUIProvider>
    </React.Fragment>
  )
}

describe('TextSamples', () => {
  it(`renders correctly`, () => {
    const tree = renderWithTheme(<Text>the quick brown fox jumps over the lazy dog</Text>)
    expect(tree.toJSON()).toMatchSnapshot()
  })
})

Actual

Both snapshot have the same text color.

Excpected

To create snapshot files with two text components and each should be its own primary400 color.

gluestack-ui Version

latest at this point

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

No response

@aymkin aymkin added the bug Something isn't working label Dec 11, 2023
@Gluant101 Gluant101 moved this from Backlog to Todo in gluestack support Dec 12, 2023
@Gluant101 Gluant101 moved this from Todo to Backlog in gluestack support Dec 13, 2023
@Gluant101
Copy link
Contributor

Thanks for reporting the issue. We'll update you on this.

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
Status: Backlog
Status: Backlog
Development

No branches or pull requests

5 participants