Jasmine Testing Angular2 Components failing on @Component annotation -


i have simple test i'm trying run through jasmine. here ts files.

unit-test.html

<html> <head>     <title>1st jasmine tests</title>     <link rel="stylesheet" href="../node_modules/jasmine-core/lib/jasmine-core/jasmine.css" />     <script src="../node_modules/systemjs/dist/system.src.js"></script>     <script src="../node_modules/angular2/bundles/angular2.dev.js"></script>     <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script>     <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>     <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script>     <!--<script src="../node_modules/zone/lib/zone.js"></script>-->  </head> <body>      <script>         // #2. configure systemjs use .js extension         //     imports app folder         system.config({             transpiler: 'typescript',             typescriptoptions: { emitdecoratormetadata: true },             packages: {                 'test': { defaultextension: 'js' },                 'app': { defaultextension: 'js' }             }         });         // #3. import spec file explicitly         system.import('test/test.spec')             // #4. wait imports load ...             //     re-execute `window.onload`             //     triggers jasmine test-runner start             //     or explain went wrong             .then(window.onload)             .catch(console.error.bind(console));     </script>  </body> </html> 

test.spec.ts

import {testcomponent} "../app/components/about/test.component"  describe('test component->', () => {     it('has name given in constructor', () => {         var t1 = new testcomponent('super cat');         expect(t1.myvalue).toequal('super cat');     });     it('does not have id given in constructor', () => {         var t2 = new testcomponent('super cat');         expect(t2.myvalue).not.toequal(1);     }); }); 

test.component.ts notice commented out component annotation

import {component} 'angular2/core';  //@component({ //    selector: 'test-component', //    templateurl: "<div></div>", //})  export class testcomponent {      constructor(value: string) {         this.myvalue = value;     }      public myvalue = '';      onkey2() {         return this.myvalue;     } } 

now if hit unit-test.html @copmonent annotation commented out following result

enter image description here

however if uncomment @component annotation line, how components defined... following error

enter image description here

can please tell me why i'm getting error. i've tried importing "reflect-metadata" no success

ok, think got it... had change script section in unit-test.html following in exact order!! have figure out how pull separate project

<script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script> <script src="../node_modules/systemjs/dist/system.src.js"></script> <script src="../node_modules/rxjs/bundles/rx.js"></script> <script src="../node_modules/angular2/bundles/angular2.dev.js"></script> <script src="../node_modules/angular2/bundles/testing.dev.js"></script> <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine.js"></script> <script src="../node_modules/jasmine-core/lib/jasmine-core/jasmine-html.js"></script> <script src="../node_modules/jasmine-core/lib/jasmine-core/boot.js"></script> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -