Skip to main content
Question

Testing Web SDK

  • July 1, 2024
  • 1 reply
  • 60 views

Forum|alt.badge.img

I have tried adding jest testing to a miro app created with create-miro-app. I get a ‘miro is not defined’ error. Is the only way to run unit tests to mock the miro object? Is it possible to install an sdk or something?

Was it helpful?

1 reply

Mettin
Mironeer
Forum|alt.badge.img+1
  • Mironeer
  • 86 replies
  • July 2, 2024

Hey @JohnW122,

Probably Jest isnt aware of the global `miro` object. a quick solution would be to add

global.miro = jest.fn()

to your test file. If your tests use other functions of miro you can also mock them. At this point we dont have a testing SDK available. Lets say you want to test `miro.ui.board.createStickyNode`

global.miro = {

  ui: {

    board: {

      createStickyNode: jest.fn()

    }

  }

}

If you need more specific help, can you share your repo?

Cheers,
Mettin