1

I'm trying to render a component using react-testing-library in an Ionic React based project. There appears to be an issue with StatusBar. The error says StatusBar does not have web implementation.

My code looks something like this:

let component

beforeEach(() => {
    component = render(
        <ThemeProvider>
                <IonReactRouter>
                    <IonRouterOutlet>
                        <Login />
                    </IonRouterOutlet>
                </IonReactRouter>
        </ThemeProvider>
    )
})

describe('snapshot', () => {
    it('should match snapshot', () => {
        const { asFragment } = component
        expect(asFragment()).toMatchSnapshot()
    })
})
johannchopin
  • 13,720
  • 10
  • 55
  • 101
Sabbir Ahmed
  • 1,468
  • 2
  • 16
  • 21

2 Answers2

3

That's no error, that's the Capacitor Plugin not having the Web Implementation, you could just ignore that or catch it everywhere with .catch(()=>{});

Mark
  • 485
  • 7
  • 14
0

Have you installed @capacitor/status-bar in /src-capacitor? (yarn add @capacitor/status-bar or npm install ....)

  • Welcome to Stack Overflow! Please phrase this as an explained conditional answer, in order to avoid the impression of asking a clarification question instead of answering (for which a comment should be used instead of an answer, compare https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead ). For example like "If your problem is ... then the solution is to .... because .... ." – Yunnosch Nov 18 '22 at 21:34