Comments (6)
@spenoir the tab directive from this repo is using templateUrl:
https://github.com/vojtajina/ng-directive-testing/blob/master/js/tabs.js#L26
You can also find more complex examples in this repo prepared by Igor Minar and myself:
https://github.com/IgorMinar/directives-workshop
Unless you've got more specific questions....
from ng-directive-testing.
Thanks for the links.
I guess I'm talking about loading fixtures in really. When I test a directive that uses a template file I get unexpected GET errors for the template. I can fix this by using jasmine-jquery.getFixtures() and manually adding the response to the templateCache, but I can't see any other more simple way of loading html into a test.
from ng-directive-testing.
@spenoir I'm a bit confused.... If you put all the templates into $templateCache as pointed out in the above links you shouldn't see any HTTP requests under unit tests. Which makes sense since you definitively don't want to trigger HTTP requests while unit testing as this would make them run slower.
Not sure what you mean by "loading fixtures" exactly, though...
from ng-directive-testing.
I'm using a templateUrl that is different to the physical disk location. Could that be causing my unexpected get request? I'm using your examples as closely as possible.
Loading fixtures means loading data into tests rather than hard coding, its fairly standard in django envs at least...
from ng-directive-testing.
@spenoir the whole point of this example is to show how to use ng-html2js
preprocessor. The example does use templateUrl. It sounds like you need to change the preprocessor configuration (cacheIdFromPath
, see https://github.com/karma-runner/karma-ng-html2js-preprocessor).
from ng-directive-testing.
@vojtajina Even I am getting this message. I am trying to load the template Url by following this example but I am getting unexpected 'GET' errors. Any idea where I could be missing.
In karma conf.js
I am loading the files as
files: [
'../app/libs/angular/angular.js',
'../app/libs/angular-mocks/angular-mocks.js',
'../app/js/controllers/*.js',
'../app/js/directives/*.js',
'karma-spec.js',
'../app/templates/helloworld.html'
],
and configuring as
preprocessors: {
'../app/js/controllers/*.js':['coverage'],
'../app/templates/helloworld.html':'html2js'
},
ngHtml2JsPreprocessor:{
stripPrefix:'../app',
moduleName: "my.templates"
},
And in the test case
loading the module as beforeEach(module('my.templates'));
from ng-directive-testing.
Related Issues (9)
- Update this example to use the testacular html2js preprocessor HOT 4
- Unit Test Karma Jasmine SyntaxError: Parse error on "&" Angular Directive binding
- getting error [launcher] Error: SyntaxError: Unexpected token . while running protractor test
- karma error: Uncaught SyntaxError: Unexpected token < HOT 11
- When templateUrl and actual file location are different HOT 7
- Getting illegal token error HOT 4
- Testing directives that have a require: ^parentDirective HOT 1
- Using two-way binding on the directive attributes fails in testing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-directive-testing.