Derek Chiang
Derek Chiang

Reputation: 3410

Testing a WebRTC application

I'm trying to test a WebRTC application. Right now the best I can do is to open several private browser windows and let them talk to each other, but this clearly doesn't scale.

I'm looking for a way to create a large number of peers on a single machine. I was looking into Phantom.js but it didn't seem to support WebRTC yet. Any suggestions?

Upvotes: 7

Views: 3066

Answers (2)

user3007799
user3007799

Reputation: 167

For MediaStream it can be used https://www.npmjs.com/package/mediastream as:

import { MediaStream as libMediaStream } from 'mediastream';

For getUserMedia() it can be used https://www.npmjs.com/package/get-user-media-promise as:

(<any>window.navigator).mediaDevices = Object.assign({}, 
  window.navigator.mediaDevices,
  { getUserMedia: require('get-user-media-promise')}
);

RTCPeerConnection, depends on your unit tests, might be mocked as:

window['RTCPeerConnection'] = () => {
  return {
    close: () => { },
    getTracks: () => { },
    addStream: () => { },
    createOffer: () => { },
    addIceCandidate: () => { },
    setRemoteDescription: () => { },
    createAnswer: () => { },
    setLocalDescription: () => { }
  };
};

Upvotes: 1

Sam Dutton
Sam Dutton

Reputation: 15279

The problem is that PhantomJS currently is based on QtWebKit, and WebRTC needs components from Chromium as well as WebKit.

It would be a lot of work for Phantom.js to re-implement all this -- and there are also issues with codec support, etc. Also occurs to me that in a headless environment it would be hard to test getUserMedia(), which is fundamental to WebRTC, but requires user interaction and can't be scripted.

Upvotes: 7

Related Questions