Closed ajcrites closed 8 years ago
@ajcrites try this one https://gist.github.com/zombiQWERTY/f01087f01506f67d4126
You are pretty much right my friend. I always relied on the demo but that is not good enough (I don't even have it linked in the new readme).
I will add a little extra code tomorrow for this.
I created a minimal application with a spec file. Check it out ;)
This is great! One thing that is weird is that I tried emulating this but I had to specify the babel loader for isparta-instrumenter, but you don't do this in your code. How is isparta-instrumenter able to work with the ES6 files for you?
There is a loader setup on webpack (that gets processed on test mode) and then some coverage config on karma.
Check the webpack part.
I am trying to get karma + webpack + angular working based on your examples, but you do not have any
.spec
file examples in the repo to confirm how things should be working. I'm currently unable to get a spec working. The app I've created works fine and I can get the tests to run, but no matter what I do I keep coming back to:I also tried cloning this repo and adding an simple
app.spec
file but it seems like it doesn't get webpacked (it will complain if I try to use an arrow function).npm test
will also complain if you try to usebeforeEach(module('app'))
. I think this may be related to my problem.I've created a gist that includes my relevant karma/webpack/test config files as well as the sample test I am trying to run
The test will run, but I get various errors at the
$controller
call. I've tried all of the following:myapp/index.js
to thetest.webpack.js
file so that it loads the module. I also have to removeimport 'angular';
from that file. This yields the same error.beforeEach(module('myapp'))
to any test -- yieldsObject is not a function (evaluating 'module('myapp')')
. If I doangular.module('myapp')
I don't get an error.angular.module('notmyapp')
does emit an error.angular-mocks
right after importingangular
in the entry point file just in case importing it after defining modules has an effect. It doesn't seem like this matters ... nothing changes.If you could include a working version of a test it would help me out -- especially if you can include specifics about where I am going wrong. It seems to me that you would also have to include your source files and not just the
.spec
/test files so that your module is loaded, but then I'm not sure whymodule('myapp')
doesn't work in tests.