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

Error on snapshot in Table component using jest & react-test-library after upgrading ant design from 4.15.6 to 4.24.1 #38448

Open
Diinz opened this issue Nov 8, 2022 · 2 comments
Labels

Comments

@Diinz
Copy link

Diinz commented Nov 8, 2022

Reproduction link

https://jsfiddle.net/fkv64bnq/

Steps to reproduce

Simple table component from ant design unable to snapshot

What is expected?

snapshot created

What is actually happening?

Cannot read properties of undefined (reading 'match')
TypeError: Cannot read properties of undefined (reading 'match')

Environment Info
antd 4.24.1
React 17.0.2
System Ubuntu 22.04.1 LTS
Browser Snapshot test in jest

"@testing-library/dom": "8.18.1",
	"@testing-library/jest-dom": "5.16.5",
	"@testing-library/react": "12.1.5",
	"@testing-library/user-event": "14.4.3",
@ilyaSy
Copy link

ilyaSy commented Nov 16, 2022

Hi! Try this

jest.mock('rc-util/lib/getScrollBarSize', () => ({
  ...jest.requireActual('rc-util/lib/getScrollBarSize'),
  getTargetScrollBarSize: jest.fn().mockReturnValue({ width: '1000px', height: '1000px' }),
}));

I have a bug during test my app and find the problem of testing antd table is in rc-util / getScrollBarSize. So we can just mock it

@Diinz
Copy link
Author

Diinz commented Nov 16, 2022

Hi @ilyaSy ty for the answer. It is not an actual solution just avoiding the problem. But it works !!
It's weird that no one has reported this bug in 6 months.

Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants