I am using Angular2 RC 1 and Angular cli to run my tests.
I have a test that calls a function from my component that uses underscore. The test fails, saying
ReferenceError: _ is not defined
I have the typings for underscore - it works fine as long as I'm not running tests. I understand that it imports underscore in my index file along with all of the other vendor JS. However, when it's running a test, I don't know how to inject the dependency. I've tried importing it with import statements, but no such luck. Any ideas?
Do you work with Karma?
Then you have to edit your karma.conf.js
Push the lodash/underscore file into the files array:
files: [
{ pattern: 'dist/vendor/lodash/lodash.js', included: true, watched: false }
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With