twilio / twilio-video-processors.js

Twilio Video Processors is a collection of video processing tools which can be used with Twilio Video JavaScript SDK to apply transformations and filters to a video track.
Other
33 stars 21 forks source link

Adds checks for window to allow compatibility with Next.js. #33

Closed brianschrameck closed 2 years ago

brianschrameck commented 2 years ago

Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.

Pull Request Details

Description

Wraps usage of window in a typeof check to avoid trying to use window when using server-side rendering in Next.js. See #32 for more details

Burndown

Before review

charliesantos commented 2 years ago

Hey @brianschrameck this looks good! Can you please add a test? Please add it here https://github.com/twilio/twilio-video-processors.js/blob/master/tests/unit/spec/utils/support.ts#L4

Here's my suggestion for the test:

  describe('For server side rendering', () => {
    let originalWindow: any;

    before(() => {
      originalWindow = root.window;
      delete root.window;
    });

    after(() => {
      root.window = originalWindow;
    });

    it('should return false', () => {
      assert.strictEqual(isBrowserSupported(), false);
    });
  });
brianschrameck commented 2 years ago

Good call, @charliesantos. Should be all set now!