Comments (5)
Please provide an isolated repro on Stackblitz/Github repo 🙏 It would help us to understand the issue.
from fluentui.
In Jest & jsdom typeof window.matchMedia
returns:
console.log("window.matchMedia: typeof", typeof window.matchMedia)
// window.matchMedia: typeof undefined
And we have already a check against it:
It looks that your env mocks window.matchMedia
without providing a proper implementation.
from fluentui.
@layershifter - In this case the partner is trying to unit test a dialog of their own. Our Dialog uses the reduced motion hook. When we test the hook, we mock the media queries. It seems like an unnecessary burden for callers of Dialog writing tests to have to mock all the internals of Dialog and any hooks it uses. The matchMedia returns an object but it doesn't have the add/remove event listener. If the hook checked that the add/remove event listener functions were non-null and functions like it does the matchMedia function, then the hook could return false without the partner needing to mock.
from fluentui.
When we test the hook, we mock the media queries. ... It seems like an unnecessary burden for callers of Dialog writing tests to have to mock all the internals of Dialog and any hooks it uses.
@GeoffCoxMSFT do I correctly understand that window.matchMedia
is mocked? If so, why is that needed to test Dialog
? As it's not required in the first place...
A minimal example of that unit test would help to understand a proper solution for this issue.
from fluentui.
Talked offline to show the affected files in the repository. In the end it was me how did not set up a mock correctly for window.matchMedia
and addEventListener
inside it.
Thank you @layershifter for the help!
from fluentui.
Related Issues (20)
- [Bug]: Cannot interact with buttons inside TableHeaderCell HOT 1
- [Bug]: Can't upgrade to package 9.53.0 HOT 3
- [Bug]: Dialog remains in DOM after close when using Jest HOT 3
- [Bug]: In browse mode, screen reader not announcing the selected/not selected state for the legends. HOT 5
- [Bug]: [FUI9][DOC] - All image of documentation site is broken HOT 1
- [Bug]: message bar icon in the Error message was changed from "X" to "!".
- [Bug]: Missing Fluent icon in tab for Storybook
- [Bug]: Storybook Accordion Sizes example is not consistent with other examples, locks all items open, has no size labels
- [Feature]: To make it easier to display the ellipsis when fluent-button's text overflows HOT 4
- [Bug]: codeowners on out of date PR's are not assigned after split-library-in-two migrations
- [Bug]: Dialog documentation could be clearer HOT 2
- [Bug]: TimePicker doesn't clear textbox when `value` prop is set to null
- [Bug]: Vertical divider min-width is always 86px
- [Bug]: Dialog fails to render if DialogSurface is in another component HOT 2
- [Bug]: Open overlay drawer fails with Vite app HOT 1
- [Feature]: New List - add support for Home/End HOT 1
- [Feature]: Tooltips should not render when Menus are open HOT 1
- [Bug]: GroupedVerticalBarChart throws error when data is empty (not null)
- [Bug]: Tree with virtualization focus on active tree item HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentui.