2013-12-17 8 views
7

タイトルは本当にすべてです。インターネットをトロールしているにもかかわらず、私はこの問題の解決策の一例を見つけていません。ここでジャスミンテスト用のイスタンブールコードカバレッジレポートを作成すると、ファントムのブラウジングバンドルで実行されます

いくつかのニアミス

をbrowserify、イスタンブール私の進行中のコードhttps://github.com/wheresrhys/on-guard/tree/browserifyである(それはbrowserify者注'branch - Gruntfile.jsはちょっと混乱しますが、間もなく整理します)。 console.logを使用して私の最初の調査は何とかbundle.src.jsがページにロードされていることを示していますが、テストが実行され(そして渡されると)bundle.src.jsのコードが実行されていないので、 1つはクロムのスペックルナーを開いたときのようにファントムに限られていますが、コードが実行されています。

+0

は、あなたはこの1つを把握しましたか?現時点でガード・プロジェクトで働いていますか? –

+0

この質問が答えを出して3年間ここにあったとはどういう意味ですか... – QueueHammer

答えて

0

私は解決策としてgrunt-browserify + browserify-istanbul + grunt-contrib-jasmine + grunt-template-jasmine-istanbulを使用しています。このソリューションには、browserifyを使用してソースファイルを構築するときにサードパーティライブラリも除外されています。

  1. 音源コード
  2. ランテスト
  3. は、最初のコードを表示し、私は後で、イスタンブールカバレッジレポートを生成する

    grunt.initConfig({ 
    browserify: { 
        // build specs using browserify 
        specs: { 
        src: ["spec/**/*Spec.js"], 
        dest: "spec/build/specs.js", 
        options: { 
         debug: true 
        } 
        }, 
        // build source files using browserify and browserify-istanbul 
        dev: { 
        options: { 
         debug: true, 
         browserifyOptions: { 
         standalone: 'abc' 
         }, 
         transform: [['browserify-istanbul', { 
         ignore: ['**/node_modules/**'], // ignore third party libs 
         defaultIgnore: true 
         }]] 
        }, 
        src: ['abc.js'], 
        dest: 'dist/abc.js' 
        } 
    }, 
    connect: { 
        server: { 
        options: { 
         port: 7000 
        } 
        } 
    }, 
    // test using jasmine, generate coverage report using istanbul 
    jasmine: { 
        coverage: { 
        src: ['dist/abc.js'], 
        options: { 
         junit: { 
          path: 'bin/junit' 
         }, 
         host: 'http://localhost:7000/', 
         specs: 'spec/build/specs.js', 
         keepRunner: true, 
         summary: true, 
         template: require('grunt-template-jasmine-istanbul'), 
         templateOptions: { 
         replace: false, // *** this option is very important 
         coverage: 'bin/coverage/coverage.json', 
         report: [ 
          { 
          type: 'html', 
          options: { 
          dir: 'spec/coverage/html' 
          } 
         }] 
         } 
        } 
        }  
    } 
    
        grunt.registerTask('specs', ['browserify:specs', 'browserify:dev', 'connect', 'jasmine']); 
    

    手順は三つに結論することができる説明します

  4. カバレッジレポートを生成する
当社のソリューションで

は、私たちはあなたの機器コードがbrowserify建物のステップでできるようになるステップ1でbrowerify-istanbulgrunt-contrib-jasminerunt-template-jasmine-istanbulステップ2でと3

browserify-istanbulを使用して、このように、我々は簡単にサードパーティのLIBSを無視することができます。しかし、grunt-template-jasmine-istanbulは再びコードを記入します。これを避けるには、オプションでreplacefalseを設定します。

参考文献:

  1. Istanbul steps
  2. broswerify-istanbul
  3. grunt-contrib-jasmine
  4. grunt-template-jasmine-istanbul - replaceオプション
関連する問題