Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active August 4, 2021 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/b037c8504f2db6443ce2ea252e916894 to your computer and use it in GitHub Desktop.
Save YonatanKra/b037c8504f2db6443ce2ea252e916894 to your computer and use it in GitHub Desktop.
(function mockDOMMatrix() {
class DOMMatrixMock extends DOMMatrix {
scale = jest.fn().mockImplementation((scaleX, scaleY) => this.setScale(scaleX, scaleY));
translate = jest.fn().mockImplementation((x, y) => this.setTranslate(x,y));
setScale(scaleX, scaleY) {
this.f = scaleY;
this.e = scaleX;
return this;
}
setTranslate(x,y){
this.b = x;
this.c = y;
return this;
}
}
global.DOMMatrix = DOMMatrixMock;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment