Open efilion opened 2 years ago
This is incredible, I've only had a brief read through as I'm very busy lately but when I get time I will try to turn this into some documentation that everyone can reference if they need to test, and I'll try to have a think about how testing could be improved/made easier as you suggested
Thank you so much for documenting this
Hello, I am Rahul a blind person. I am regular screen reader user. As mentioned here I also notice that the library does not work well with the screen readers. . This can have huge impact. any website wich uses this library, will be completely in accessible for blind people like me. If allowed ,I would like to work and help in fixing this.
Had a hell of a time trying to figure this one out. Thought I would share the solution I found here to help anyone else trying to set up automated Jest tests with ReactChessboard.
Solution for writing automated tests with Jest
npx create-react-app react-chessboard-jest-testing
,cd react-chessboard-jest-testing
npm i react-chessboard
npm i --save-dev react-dnd-test-utils react-dnd-test-backend
Getting Jest to play nicely with ESM modules
/* act and await tick to ensure setup animation completes
afterEach(() => { cleanup() })
test('e2 to e4', async () => { let e2pawn = document.querySelector('[data-square=e2] [draggable]'); let e4square = document.querySelector('[data-square=e4]')
expect(e2pawn).toBeInTheDocument(); expect(e4square.querySelector('[draggable]')).not.toBeInTheDocument(); await fireDragDrop(e2pawn, e4square); expect(e2pawn).not.toBeInTheDocument(); expect(e4square.querySelector('[draggable]')).toBeInTheDocument(); })
test('can find white pawn', () => { render( <>
)
let e2pawn = screen.getByRole('widget', { name: /white e2 pawn/i }); expect(e2pawn).toBeInTheDocument(); })