dooboo-ui-legacy icon indicating copy to clipboard operation
dooboo-ui-legacy copied to clipboard

Problem with snapshot testing environment of CalendarCarousel

Open minseungseon opened this issue 3 years ago • 4 comments

Describe the bug yarn testing fails in packages/tests/CalendarCarousel.test.tsx

To Reproduce

  1. $yarn jest packages/__tests__/CalendarCarousel.test.tsx

  2. Then I get following error message.

$ tsc
 FAIL  packages/__tests__/CalendarCarousel.test.tsx
  ● [Calendar] › should render without crashing

    expect(received).toMatchSnapshot()

    Snapshot name: `[Calendar] should render without crashing 1`

    - Snapshot  - 24
    + Received  + 24

    @@ -62,11 +62,11 @@
                      "textAlign": "center",
                      "width": 300,
                    }
                  }
                >
    -             July
    +             7월
                </Text>
                <Text
                  style={
                    Object {
                      "fontSize": 12,
    @@ -114,11 +114,11 @@
                      "fontSize": 20,
                      "textAlign": "center",
                    }
                  }
                >
    -             S
    +             일
                </Text>
              </View>
              <View
                style={
                  Object {

...

      16 |   it('should render without crashing', () => {
      17 |     const rendered = renderer.create(component());
    > 18 |     expect(rendered).toMatchSnapshot();
         |                      ^
      19 |     expect(rendered).toBeTruthy();
      20 |   });
      21 | });

      at Object.<anonymous> (packages/__tests__/CalendarCarousel.test.tsx:18:22)

 › 1 snapshot failed.
Snapshot Summary
 › 1 snapshot failed from 1 test suite. Inspect your code changes or run `yarn run jest -u` to update them.

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   1 failed, 1 total
Time:        2.181 s, estimated 4 s
Ran all test suites matching /packages\/__tests__\/CalendarCarousel.test.tsx/i.
error Command failed with exit code 1.

Expected behavior This test failure seems to be happening only in my terminal.

Screenshots X

Desktop (please complete the following information):

  • OS: [mac OS]

Smartphone (please complete the following information): X

Additional context X

minseungseon avatar Aug 02 '20 04:08 minseungseon

I think this issue is related to localization.

JeffGuKang avatar Aug 02 '20 04:08 JeffGuKang

Oh yes! We should fix test env to English. This would be a good contribution.

hyochan avatar Aug 02 '20 04:08 hyochan

#338 is related issue. How about to write test codes without comparison snapshot?

JeffGuKang avatar Sep 15 '20 13:09 JeffGuKang

Here's a way to compare snapshots of specific parts only. https://jestjs.io/docs/en/snapshot-testing#property-matchers

JeffGuKang avatar Sep 22 '20 00:09 JeffGuKang