function replaceCanvasContext(el) {
  el.getContext = function () {
    return {
      fillRect: function () {},
      clearRect: function () {},
      getImageData: function (x, y, w, h) {
        return {
          data: new Array(w * h * 4),
        };
      },
      putImageData: function () {},
      createImageData: function () {
        return [];
      },
      setTransform: function () {},
      drawImage: function () {},
      save: function () {},
      text: function () {},
      fillText: function () {},
      restore: function () {},
      beginPath: function () {},
      moveTo: function () {},
      lineTo: function () {},
      closePath: function () {},
      stroke: function () {},
      translate: function () {},
      scale: function () {},
      rotate: function () {},
      circle: function () {},
      arc: function () {},
      fill: function () {},

      //
      // Following added for vis.js unit tests
      //

      measureText: function (text) {
        return {
          width: 12 * text.length,
          height: 14,
        };
      },
    };
  };
}
Replace element's getContext method with a do nothing mock.
@param {HTMLElement} el - The element whose getContext will be mocked.