Search code examples
reactjstypescriptjestjsiconsfluent

Jestjs - FluentUI - suppress "The icon 'X' was used but not registered" warning


I'm writing a react app that uses fluentUI.

while working on the system everything is fine (ofc I'm calling initializeIcons() function). however, when I'm running my test using jest, I keep getting the warning about 100 times, causing the output to be very messy and not understandable

how can i suppress the warning (even temporarily)?


Solution

  • According to fluent documentation: (https://github.com/microsoft/fluentui/wiki/Using-icons#test-scenarios)

    import { setIconOptions } from '@fluentui/react/lib/Styling';
    
    // Suppress icon warnings.
    setIconOptions({
      disableWarnings: true
    });