You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue with how traverson-angular wraps and overwrites the prototype-methods of Traverson's Builder when testing with angular-mocks.
Angular-mocks re-initializes all dependencies for every test, causing the traversonAngular factory-function to execute before every unit test, which in turn wraps the Builder's prototype-methods multiple times. Once they're wrapped multiple times the promises don't properly resolve anymore for the client code.
I fixed it by moving the originalMethods initialisation outside the factory method. I'll send the pull request in a minute.
I've added a dependency to angular-mocks and a spec that executes two tests after each other, hope that's ok for you. Without the change in the code the second test will fail with a time out.
Thank you for creating Traverson!
Thomas.
The text was updated successfully, but these errors were encountered:
Seems I have broken this again with some refactorings in Traverson.
More specifically, after a relatively big refactoring in in traverson (418abd5365a) these tests stopped working.
I tried to debug it but could not pin it down. The mocked httpBackend still responds but calling deferred.resolve (traverson-angular.js, line 49) does not trigger the then-function in the tests. Tbqh, I have no idea why. The mentioned commit added an additional level of asynchronicity to the call flow in traverson but since we are back in traverson-angular.js and actually calling deferred.resolve(result) I don't believe the problem is in traverson. I'm quite at a loss here.
@meyertee Thomas, I know it's been a while but would it be possible for you to take a look on this? Maybe you see something that I am missing.
Well, never mind. After writing this, I digged some more. I totally forgot about the silver bullet of JS, just add a little setTimeout in the right spot, all problems go away :-/
Hi,
I ran into an issue with how traverson-angular wraps and overwrites the prototype-methods of Traverson's Builder when testing with angular-mocks.
Angular-mocks re-initializes all dependencies for every test, causing the traversonAngular factory-function to execute before every unit test, which in turn wraps the Builder's prototype-methods multiple times. Once they're wrapped multiple times the promises don't properly resolve anymore for the client code.
I fixed it by moving the
originalMethods
initialisation outside the factory method. I'll send the pull request in a minute.I've added a dependency to angular-mocks and a spec that executes two tests after each other, hope that's ok for you. Without the change in the code the second test will fail with a time out.
Thank you for creating Traverson!
Thomas.
The text was updated successfully, but these errors were encountered: