title: Karma-webpack: Unknown provider: LeaveServiceProvider <- LeaveService
body: <p>My app works like a charm but I can't run my tests with</p>
  
  <pre><code>$ yarn test
  # node node_modules/karma/bin/karma start ./karma.conf.js --single-run
  </code></pre>
  
  <h3>Version</h3>
  
  <pre><code>    "angular-mocks": "~1.5.10",
      "karma-webpack": "^2.0.1",
      "webpack": "^1.14.0",
      "webpack-dev-server": "^1.16.2",
  </code></pre>
  
  <h3>Error</h3>
  
  <pre><code>PhantomJS 2.1.1 (Linux 0.0.0) leave API service create(): should create a leave FAILED
          Error: [$injector:unpr] Unknown provider: LeaveServiceProvider &lt;- LeaveService
          http://errors.angularjs.org/1.5.10/$injector/unpr?p0=LeaveServiceProvider%20%3C-%20LeaveService (line 4674)
          static/app.min.js:4674:87
          getService@static/app.min.js:4827:40
          static/app.min.js:4679:49
          getService@static/app.min.js:4827:40
          injectionArgs@static/app.min.js:4852:69
          invoke@static/app.min.js:4874:32
          WorkFn@node_modules/angular-mocks/angular-mocks.js:3130:26
          inject@node_modules/angular-mocks/angular-mocks.js:3100:46
          test/leave.service.tests.js:55:23
          loaded@http://localhost:9876/context.js:151:17
          inject@node_modules/angular-mocks/angular-mocks.js:3097:28
          test/leave.service.tests.js:55:23
          loaded@http://localhost:9876/context.js:151:17
          TypeError: undefined is not an object (evaluating '$httpBackend.expectPOST') in test/leave.service.tests.js (line 64)
          test/leave.service.tests.js:64:16
          loaded@http://localhost:9876/context.js:151:17
          TypeError: undefined is not an object (evaluating '$httpBackend.verifyNoOutstandingExpectation') in test/leave.service.tests.js (line 114)
          test/leave.service.tests.js:114:16
          loaded@http://localhost:9876/context.js:151:17
  PhantomJS 2.1.1 (Linux 0.0.0): Executed 1 of 5 (1 FAILED) (skipped 4) ERROR (0.042 secs / 0.01 secs)
  </code></pre>
  
  <h3>Karma.conf.js</h3>
  
  <pre><code>const webpack = require('webpack');
  const webpackConfig = require('./webpack.config.js');
  
  module.exports = function (config) {
      config.set({
          basePath: './',
          frameworks: ['jasmine', 'mocha', 'chai'],
          files: [
              './static/app.min.js',
              'node_modules/angular-mocks/angular-mocks.js',
              {pattern: 'test/leave.service.tests.js'}
          ],
          preprocessors: {
              'test/leave.service.tests.js': ['webpack']
          },
          webpack: {
              module: webpackConfig.module,
              plugins: webpackConfig.plugins
          },
          webpackMiddleware: {
              stats: 'errors-only'
          },
          notifyReporter: {
              reportEachFailure: true,
              reportSuccess: false
          },
          plugins: [
              'karma-phantomjs-launcher',
              'karma-jasmine',
              'karma-webpack',
              'karma-mocha',
              'karma-chai'
          ],
          browsers: ['PhantomJS']
      });
  };
  </code></pre>
  
  <h3>webpack.conf.js</h3>
  
  <pre><code>const webpack = require('webpack');
  const path = require('path');
  
  module.exports = {
      entry: {
          app: './src2/app.js'
      },
      output: {
          path: path.resolve(__dirname, './static'),
          publicPath: '/static/',
          filename: 'app.min.js'
      },
      plugins: [
          new webpack.ProvidePlugin({
              $: 'jquery',
              jQuery: 'jquery',
              'window.jQuery': 'jquery',
              moment: 'moment'
          })
      ],
  
      resolve: {
          root: path.resolve('./src2'),
          extensions: ['', '.js']
      },
      module: {
          loaders: [
              {test: /\.css$/, loader: 'style-loader!css-loader'},
              {test: /\.scss$/, loader: 'style-loader!css-loader!sass-loader'},
              {test: /\.html$/, loader: 'html-loader'},
              {test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&amp;mimetype=application/font-woff'},
              {test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&amp;mimetype=application/font-woff'},
              {test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&amp;mimetype=application/octet-stream'},
              {test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'},
              {test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=8192&amp;mimetype=image/svg+xml'}
          ]
      },
      devServer: {
          port: 8080,
          proxy: {
              '/api': {
                  target: {
                      host: '0.0.0.0',
                      protocol: 'http:',
                      port: 8000
                  }
              }
          }
      }
  };
  </code></pre>
  
  <h3>test/leave.service.js</h3>
  
  <pre><code>var chai = require('chai');
  var assert = chai.assert;
  
  describe('leave API service', function () {
      var service;
      var $httpBackend;
  
  
      beforeEach(inject(function (_$httpBackend_, LeaveService) {
          $httpBackend = _$httpBackend_;
          service = LeaveService;
      }));
  
      it('create(): should create a leave', function (done) {
          var foo = 'bar';
  
          assert.equal(foo, 'bar');
          done();
      });
  });
  </code></pre>
  
  <h3>Question</h3>
  
  <p>What's the matter here ?</p>
  
  <p>related: <a href="https://stackoverflow.com/q/41618626/802365">Karma-webpack+angular TypeError: undefined is not an object (evaluating &#39;$httpBackend.expectPOST&#39;</a></p>