swiper
swiper copied to clipboard
Swiper/React - Active class not set within unit-test
Check that this is really a bug
- [X] I confirm
Reproduction link
https://codesandbox.io/s/jest-testing-react-forked-qxoe7b
Bug description
It seems while in the browser the swiper-slide-active class is set and switches everytime a swipe happened, this bevahiour is not reproducable within a unit test.
My intention is to test if a function was triggered on a slide-change, but since the swiper-slide-active class is not even set in the jsDOM environment, it seems that the swiper is not even properly initiated.
Expected Behavior
The expected behaviour is, that the active class swiper-slide-active is also set when rendering the swiper within a unit test, using jest/react.
Actual Behavior
The swiper-slide-active is never set, which is an indicator, that the swiper container is never properly initiated.
See provided sandbox environment.
Swiper version
8.1.4
Platform/Target and Browser Versions
jsDOM environment
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- [X] Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- [X] I'm willing to open a PR
We encountered the same issue in Angular. Are there any workarounds?
Unfurtunately the only workaround for this is skip the test 🤦🏻♂️
Sorry to say this. Is unfurtunate, that noone is reacting to this
Having the same issue.
Also facing the same issue.
I am too.
I am too 🫤
Issue is closed because of outdated/irrelevant/not actual/needed more information/inactivity.
If this issue is still actual and reproducible for latest version of Swiper, please create new issue and fill the issue template correctly:
- Clearly describe the issue including steps to reproduce when it is a bug.
- Make sure you fill in the earliest version that you know has the issue.
- Provide live link or JSFiddle/Codepen or website with issue