1
我試圖用sinon.js與此代碼(requirebin)上的WebSocket建設窺探窺探:興農上的WebSocket
sinon = require('sinon');
sinon.spy(window, 'WebSocket');
// throws an error (see console)
new window.WebSocket("ws://example.com");
在Chrome中失敗與Uncaught TypeError: Failed to construct 'WebSocket': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
在Safari或者不與PhantomJs TypeError: Attempted to wrap object property WebSocket as function
我在做什麼錯?