Error importing @zoom/videosdk in Jest

Description

Hi, :wave:, I’m getting an error when running Jest (jsdom) test and I try to import @zoom/videosdk.

Browser Console Error

Test suite failed to run

TypeError: Cannot read property 'subtle' of undefined

> 1 | import ZoomVideo from '@zoom/videosdk';
    | ^
  2 | import { eventNames } from '../../events';
  3 | import type { SurfaceType } from '../../surface';
  4 | import { generateVideoToken } from './video-call-auth';

  at Object.<anonymous> (node_modules/@zoom/videosdk/dist/index.js:1:100082)
  at Object.<anonymous> (src/interface/video-calls/video-call.js:1:1)

Which Web Video SDK version?

1.1.6

Video SDK Code Snippets
The code snippets that are causing the error / issue so we can reproduce.

To Reproduce(If applicable)
Steps to reproduce the behavior:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Screenshots
If applicable, add screenshots to help explain your problem.

Device (please complete the following information):

  • Device: Macbook Pro & Codeship
  • OS: macOS 11.6, Unbutu linux
  • Browser: Chrome
  • Browser Version: Version 95.0.4638.69 (Official Build) (x86_64)

Additional context
Add any other context about the problem here.

Hey @Bee ,

What version of Node JS are you using?

Just looking here Crypto.subtle - Web APIs | MDN and that’s only available in version 15.0+ of Node. Assuming Crypto.subtle is what’s falling over in the zoom code.

Cheers,
Nick

I was using node version 12.22.0 when I posted. Switched to 15.14.0. Same error.

Also tried node version 16.13.1. Same error. Jest version is 27.2.4.

I ended up creating a module mock for videosdk. See, javascript - Jest: How to globally mock node-uuid (or any other imported module) - Stack Overflow

Hey @Bee ,

Did you get it working with that approach? @nickuk , thanks for the suggestion here! :slight_smile:

Thanks,
Tommy

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.