Skip to content

Instantly share code, notes, and snippets.

@seogi1004
Created January 7, 2019 11:55
Show Gist options
  • Save seogi1004/91ea7bbc7c65582836f65cd127e42481 to your computer and use it in GitHub Desktop.
Save seogi1004/91ea7bbc7c65582836f65cd127e42481 to your computer and use it in GitHub Desktop.
import sinon from 'sinon';
const createElement = global.document.createElement;
const FAKECanvasElement = {
getContext: jest.fn(() => {
return {
fillStyle: null,
fillRect: jest.fn(),
drawImage: jest.fn(),
getImageData: jest.fn(),
};
}),
};
sinon.stub(global.document, 'createElement')
.callsFake(createElement)
.withArgs('canvas')
.returns(FAKECanvasElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment