title: Testing Angular2 / TypeScript pipe with Jasmine
body: <p>I have an Angular2 with TypeScript application setup with very basic Jasmine tests. I want to test one of my pipes.</p>
  
  <p>lpad.pipe.ts</p>
  
  <pre class="lang-js prettyprint-override"><code>import {Pipe, PipeTransform} from '@angular/core';
  @Pipe({
      name: 'lpad'
  })
  export class LPadPipe implements PipeTransform {
      transform(value: any, args: string[]): any {
         let pad = args[0];
         return (pad + value).slice(-pad.length);
      }
  }
  </code></pre>
  
  <p>usage in html template:</p>
  
  <pre class="lang-js prettyprint-override"><code>{{size.SizeCode | lpad:['0000']}}
  </code></pre>
  
  <p>lpad.pipe.spec.ts - My test (which doesn't work)</p>
  
  <pre class="lang-js prettyprint-override"><code>import { LPadPipe } from './lpad.pipe';
  
  describe('LPadPipe'), () =&gt; {
      let pipe: LPadPipe;
  
      beforeEach(() =&gt; {
          pipe = new LPadPipe();
      });
  
      it('transforms "1" to "0001"', () =&gt; {
          let value: any = "1";
          let args: string[] = ['0000'];
  
          expect(pipe.transform(value, args)).ToEqual('0001')
      });
  
  }
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Error: TypeError: Cannot read property 'length' of undefined(…)
  </code></pre>
  
  <p>I think the problem is with the "value" and "args" of my test. Any idea how to resolve? </p>