title: Getting tz is not a function error when testing a method in Angular 2 service that uses moment-timezone
body: <p>I am getting <code>__WEBPACK_IMPORTED_MODULE_2_moment__.tz is not a function</code> when testing a method that uses <code>moment.tz(time)</code> functionality. 
  When I test just a dummy function that uses <code>moment.js</code> everything is alright.</p>
  
  <p>I checked karma and webpack configs but they don't mention moment anywhere. By my reasoning if moment works in unit-tests like that without being explicitly mentioned in webpack and karma configs, so should moment-timezone.</p>
  
  <p>Here is the unit test file for the service:</p>
  
  <pre><code>//note.service.spec.ts
  import {TestBed, inject} from '@angular/core/testing';
  import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from "@angular/platform-browser-dynamic/testing";
  import {NoteService} from './note.service';
  
  import * as moment from 'moment'; //xavtodo: maybe not needed
  
  describe('NoteService', () =&gt; {
    let service: NoteService;
  
    beforeEach(() =&gt; {
      TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting())
          .configureTestingModule({
            providers: [NoteService]
          });
    });
  
    afterEach(() =&gt; {
      TestBed.resetTestEnvironment();
    });
  
    beforeEach(inject([NoteService], (s: NoteService) =&gt; {
      service = s;
    }));
  
    it('should be created', inject([NoteService], (service: NoteService) =&gt; {
      expect(service).toBeTruthy();
    }));
  
    it('DUMMY WITH MOMENTJS', inject([NoteService], (service: NoteService) =&gt; { //so this one is working with moment.js
        expect(service.dummy()).toBeTruthy();
    }));
  
    it('DUMMY WITH MOMENT-TIMEZONE', inject([NoteService], (service: NoteService) =&gt; { //this one isn't with moment timezone
      expect(service.dummytz()).toBeTruthy();
    }));
  
  });
  </code></pre>
  
  <p>The <code>dummy</code> and <code>dummytz</code> functions in note.service.ts that I am testing to isolate the error:</p>
  
  <pre><code>dummy(): Moment{
    return moment();
  }
  
  dummytz(): Moment{
    return moment.tz('Europe/London');
  }
  </code></pre>
  
  <p>Obviously, it looks like the tz() function is not defined on moment, webpack doesn't pick up on the moment-timezone in unit tests, but it picks it alright in the application.</p>
  
  <p>This is <code>webpack.unit.test.js</code> config file:</p>
  
  <pre><code>const webpack = require('webpack');
  const helpers = require('./helpers');
  const commonConfig = require('./webpack.common.js');
  const ExtractTextPlugin = require('extract-text-webpack-plugin');
  
  console.log('///////////////////////////UNIT TEST');
  
  module.exports = {
      devtool: 'inline-source-map',
  
      node: {
          fs: 'empty'
      },
  
      resolve: {
          extensions: ['.ts', '.js']
      },
  
      module: commonConfig.module,
  
      plugins: [
          new webpack.ContextReplacementPlugin(
              // The (\\|\/) piece accounts for path separators in *nix and Windows
              /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
              helpers.root('./src'), // location of your src
              {} // a map of your routes
          ),
  
          new ExtractTextPlugin({ filename: 'main.css', disable: false, allChunks: true})
      ]
  }
  </code></pre>