Given the following code snippet, how would you create a Jasmine spyOn test to confirm that doSomething gets called when you run MyFunction?  function MyFunction() {     var foo = new MyCoolObject();     foo.doSomething(); };   Here's what my tes...
I'm trying to spy window.document with sinon.js. What I do is this:  var document = {     getElementById = function() {} }  sinon.spy(document, "getElementById").withArgs("foo").returnValues = ["bar"];   What I expect from...
I am having trouble asserting that my filter has been called after a promise has been returned.  This code is called from a controller which then pulls the data to filter from a http GET service:  getPermissions(){     return this.DataService.getPerm...
My component has the following function:    updateTransactions() {     let notes = this.createNotes()      let delTransactions = this.createDelTransactions()     this.noteService.createNote(notes[0])     this.noteService.getNoteCreated().subscribe((r...
I need to test whether my callback was called n number of times and always returned true. Here is my test callback function in typescript:    const checkBlockTransaction = (block: ILogsBlock) => {   const tx = transactions.find(element => eleme...
I have some code that executes after a promise is resolved. I'm trying to spy on a method that should be invoked post-promise resolution but I'm having problems with my tests finishing execution before the call to the spied on method is invok...
I have an angular service.  Inside this service I have an object with a function, that references another function on the service. (Code below)  I want to use Jasmine (1.3) to spy on my service function, to verify that when the object's function...
I am trying to check if a function has been called yet in my tests. I receive the error TypeError: Cannot read property 'match' of undefined when trying to do this. I have setup my code to use sinon.spy() on my function and then check the cal...
I'm trying to test that certain function is called in a callback, however I don't understand how to wrap the outer function. I'm using mocha as my testing suite, with chai as my assertion library, and sinon for my fakes.   fileToTest.js...
I'm writing integration tests and want to simulate errors in underlying calls.  I know how to do it with sandboxing internal calls, but I want to do some blackbox testing without using Sinon's sandbox on internals but on passed parameters.  I...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.