seriema / angular-apimock

Automatically route your API calls to static JSON files, for hiccup free front–end development.

Home Page:johansson.jp/angular-apimock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Testing directives with templateUrl returns blank templates

Elecash opened this issue · comments

I have a few directives with templateUrl and when I add this module tests stop working me.

 PhantomJS 1.9.8 (Mac OS X 0.0.0) Unit testing login process Should contains the login form FAILED
    Expected '' to contain '<form name="loginForm" ng-submit="ctrl.onSubmit()" novalidate="" class="ng-pristine ng-invalid ng-invalid-required">'.

Hmm are those templates using the same URL prefix as your API (apiPath)? We're assuming the API lives in it's own base url so it's not mixed with static content like HTML templates or other non data API things.

It happens with default values, so no, it should not be in the same path.

Do you have some code I can check?

I will try to set up an example on Codepen soon :)

Thanks! Don't let that hold you up though. If you have something on Github already or if you just write down some data (API call url, url of templates, the apimock config, etc) that could work too.

No, sorry, this is closed source code for a startup.

But no problem, I will try to set up something this afternoon if I have time, ok?

Hi,

I've created this repo with my problem.

https://github.com/Elecash/angular-apimock-test

Follow instructions and you will see the problem. Install dependencies, run "gulp test" and tests should fail.

Open this file: https://github.com/Elecash/angular-apimock-test/blob/master/scripts/hello-world.js

If you comment line 12 and uncomment line 11 tests pass.

Wow! Thank you! I'll look into it asap, but I might not have a fix until the weekend.

No problem. Now I'm using a workaround with the ngMockE2E module (I should write a post about it), but this module is a cleaner solution for me :)

I tried out your sample and that is indeed odd! I'll need to look into it more. Bonus hugs if you're able to fork and add a test for this. =)

@Elecash Sorry, I haven't forgotten about this but I haven't been able to write an automated test for this. It might require E2E testing. Any chance you'd be willing to help with that? As soon as I have a fully reproducible and automated test for it I'll be able to fix it more confidently and know that no future release will get a regression bug.

The truth is that I'm not working on that project anymore so I just don't need this, sorry!