Skip to content

Instantly share code, notes, and snippets.

@sgml
Created January 18, 2019 03:02
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 sgml/6e616532814369e9fcf17da2b5372dff to your computer and use it in GitHub Desktop.
Save sgml/6e616532814369e9fcf17da2b5372dff to your computer and use it in GitHub Desktop.
AutoSpy
var spy = 'window.releaseEvents()'.replace(/^/,"spyOn(").replace(/\.([a-zA-Z]+)/, ", '$1'").replace(/[(][)]+$/,')');
var expect = 'window.releaseEvents()'.replace(/^/, "expect('").replace(/[(][)]+/, '').replace(/$/,"').toHaveBeenCalled()")
console.log('spy: ' + spy);
console.log('expect: ' + expect);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment