GithubHelp home page GithubHelp logo

karma-remap-istanbul's People

Contributors

bryanforbes avatar delasteve avatar marcules avatar marines avatar mateusz-j avatar mattlewis92 avatar maxday avatar mhanoglu avatar onaips avatar vepasto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

karma-remap-istanbul's Issues

Exclude files from report

First I want to thank you for awesome job, karma-remap-istanbul is great help!

I am looking for option to exclude *.spec.* files from istanbul reports and I see that the most suggested way on StackOverflow is to exclude such files in preprocessors pattern, like this:

'**/!(*spec).js': ['coverage'],

It looks reasonable but in my case I use TypeScript and webpack, as well as karma-remap-istanbul. And I need to put all involved scripts through it or it wont work. Plus karma-remap-istanbuldoes not requirecoverage` preprocessor, it just adds to report all the files.

This is where I stuck: I need to exclude *.spec.* files from final report BUT I need to keep them going through preprocessors. My preprocessor lines look like this:

preprocessors: {
    '**/*.tsx': ['webpack', 'sourcemap'],
    '**/*.ts': ['webpack', 'sourcemap'],
}

Am I wrong and there is a way to exclude specs? Or if there is no such option, is it possible to add it?
Thanks.

Doesn't work in the first/fresh run

Hi ya, when I run karma for the first time the following message is printed in the console: Couldn't find any specified files, exiting without doing anything.

Then, if I attempt to run it again, I get: Not all files specified in sources could be found, continue with partial remapping.. Which is okay for now (only the files with spec are included in coverage).

So. It looks like that there's a race condition going on here where the file coverage.json hasn't yet been create during the first run.

Does it make sense?

Starting a new test run before the previous one completes crashes karma

14 12 2016 22:05:20.452:ERROR [karma]: TypeError: Cannot read property 'get' of null
    at /Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma-remap-istanbul/index.js:42:35
    at Array.forEach (native)
    at Collection.forEach (/Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma/lib/browser_collection.js:93:21)
    at /Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma-remap-istanbul/index.js:41:16
    at KarmaRemapIstanbul.onRunComplete (/Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma-remap-istanbul/index.js:52:7)
    at Server.<anonymous> (/Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma/lib/events.js:13:22)
    at emitTwo (events.js:111:20)
    at Server.emit (events.js:191:7)
    at Timeout._onTimeout (/Users/mattlewis/Code/open-source/angular-calendar/node_modules/karma/lib/executor.js:51:17)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

It's caused by the coverageMap getting cleared when the new run starts

Feature: Exclude files from coverage

It will be useful to be able to exclude certain files from coverage.

Both, istanbul and remap-istanbul accept the exclude option, but the any configuration of this library is not passed to them.

I'm working on it, in case I can find out a way to do it properly (which I'm not sure at this moment), it would be ok to make a pull request?

Couldn't find any specified files, exiting without doing anything.

Report is not generated as if it can't see any files even though all tests executed. Am I missing some settings?

Chrome 49.0.2623 (Mac OS X 10.11.2): Executed 62 of 63 (skipped 1) SUCCESS (3.278 secs / 3.271 secs)
Couldn't find any specified files, exiting without doing anything.

Here is my karma.config

files: [
  './src/testing/settings.js',
  'gulp-bootstrap.js',
  './src/**/*.js'
],
exclude: [
  './src/components/**/*.min.js'
],
jspm: {
  //packages: 'jspm_packages/',
  loadFiles: ['./src/**/*.spec.js'],
  serveFiles: ['./src/**/*.js', './src/**/*.map', './src/**/*.ts']
},
reporters: ['progress', 'karam-coverage', 'karma-remap-istanbul'],
remapIstanbulReporter: {
  src: 'coverage/report.json',
  reports: {
    lcovonly: 'coverage/lcov.info',
    html: 'coverage/html/report'
  },
  timeoutNotCreated: 1000, // default value
  timeoutNoMoreFiles: 1000 // default value
},
preprocessors: {
  './**/*.js': ['karma-coverage', 'coverage']
},

1.0

I think this module is relatively stable now, having a quick flick through the open issues it seems most of them are resolved by recently merged or outstanding PRs. There are a few more things I think we should do before putting a 1.0 label on the module

  • review and merge outstanding PRs, then cut a 0.3.0 release with the new features + fixes
  • review all open issues and close any that are now resolved by the new PRs
  • setup tests (a couple of e2e that uses karmas API and mocks nothing would be best)
  • setup eslint
  • setup travis that runs the tests and the linter
  • add more examples (TS karma preprocessor, system.js, anything else??) -> both of these come with remap istanbul integrated
  • upgrade remap-istanbul to latest -> waiting on 0.9.0 to land
  • drop support for node 0.12 (at the end of the year)

cc @mateuszjuszkiewicz @delasteve

Remapped Coverage Timeout Doesn't Cause Build Failure

I'm not exactly sure how to reproduce this as all attempts to purposefully cause chrome to timeout have failed, but we have a Jenkins job setup on a build serve that does testing/code coverage checking and then builds an artifact and deploys it.

During one of our builds we noticed the following

�[33m10 02 2017 09:47:31.719:WARN [launcher]: �[39mChrome was not killed in 2000 ms, sending SIGKILL.
�[31m
Waiting for remapped coverage source timed out…
�[39m:ngBuildProd

> [email protected] build C:\jenkins\workspace\Angular-Builds\angular-build-template

Normally I would expect the build to fail if code coverage timed out, but instead, as indicated by the last line of the build log, the app just keeps building as if nothing is wrong. This has allowed files with low code coverage to escape out into our production repo.

I think it is a mistake to not have the remapper return something other than ERROR_SUCCESS in this situation.

Files Not Found on CentOS

We have a the configuration below which works fine on OS X using karma-remap-istanbul 0.1.0:

    remapIstanbulReporter: {
      src: 'reports/coverage.json',
      reports: {
        lcovonly: 'reports/ts-ut.lcov',
        html: 'reports/html'
      },
      timeoutNotCreated: 5000,
      timeoutNoMoreFiles: 1000
    },

But on CentOS it fails with 'Could not find any specified files, exiting without doing anything'. I have tried CentOS 7 and 6.5. Same result.

I put in an issue with chokidar:

paulmillr/chokidar#514 (comment)

But the owner thinks that the settings being used by karma-remap-istanbul might be the issue.

[Bug] Could not find sourcemap for ts file

** Bug report **
I'm making a Node app with typescript and webpack, it was working fine with the istanbul-instrumenter-loader and the coverage reporter, however when i added this repo it breaks like so:

Error: Could not find source map for: "/Users/aplicaciones2/Documents/tao-graphql-api/src/server.ts"

** Config file **

// karma.conf.ts
import webpackConfig from './config/webpack.test'; // the settings that are common to prod and dev
// import karma from 'karma';

const srcGlob = 'src/**/!(*.spec|*.d).ts';
const testGlob = 'src/**/*.spec.ts';
const webpackEnv = { env: 'test' };

export default (config) => {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    // Fix for typescript mime type to send ts files to browser for testing
    mime : {
      'text/x-typescript': [
        'ts',
        'tsx'
      ]
    },

    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'source-map-support'],

    // list of files / patterns to load in the browser
    files: [
      // srcGlob,
      // './node_modules/core-js/index.js',
      testGlob
    ],

    // list of files to exclude
    exclude: [
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
      // [srcGlob]: [ 'webpack', 'sourcemap', 'coverage' ],
      // './node_modules/core-js/index.js': [ 'webpack', ],
      [testGlob]: [ 'webpack', 'sourcemap' ],
    },

    webpack: webpackConfig(webpackEnv),
    webpackMiddleware: {noInfo: true},

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    // reporters: ['progress'],
    reporters: ['progress', 'notification', 'coverage', 'karma-remap-istanbul'],
    // reporters: ['progress', 'notification', 'coverage'],
    // coverageReporter: {
    //   dir: 'coverage/',
    //   instrumenterOptions: {
    //     istanbul: { noCompact: false }
    //   },
    //   reporters: [
    //     { type: 'lcov', subdir: '.' },
    //     { type: 'json', subdir: '.' },
    //     { type: 'text-summary' },
    //   ],
    // },
    remapIstanbulReporter: {
      reports: {
        html: 'coverage'
      }
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values:
      // config.LOG_DISABLE ||
      // config.LOG_ERROR ||
      // config.LOG_WARN ||
      // config.LOG_INFO ||
      // config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['NodeWebkit'],

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  });
};

Latest release causes build issues

I have a PR to update to the latest version in one of my projects. The build is broken:

20 12 2016 11:06:05.071:ERROR [karma]: Error: No element indexed by 1
    at ArraySet_at [as at] (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/source-map/lib/array-set.js:92:9)
    at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/source-map/lib/source-map-consumer.js:619:34)
    at getMapping (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/getMapping.js:27:26)
    at getMappingResolved (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/CoverageTransformer.js:204:46)
    at remapBranch (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/remapBranch.js:14:19)
    at /home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/CoverageTransformer.js:214:44
    at Array.forEach (native)
    at CoverageTransformer.addFileCoverage (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/CoverageTransformer.js:210:42)
    at /home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/CoverageTransformer.js:268:14
    at Array.forEach (native)
    at CoverageTransformer.addCoverage (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/CoverageTransformer.js:266:24)
    at /home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/remap.js:48:13
    at Array.forEach (native)
    at remap (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/remap-istanbul/lib/remap.js:47:16)
    at KarmaRemapIstanbul.onRunComplete (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/karma-remap-istanbul/index.js:58:21)
    at Server.<anonymous> (/home/travis/build/redux-bootstrap/redux-bootstrap-example/node_modules/karma/lib/events.js:13:22)

You can see a full error log at https://travis-ci.org/redux-bootstrap/redux-bootstrap-example/builds/185394142

Thanks!

Why don't work your example with webpack on Windows PC?

I'm receiving blank reports when I use npm run test on Windows PC:

image


But npm run test work on MacOS:

image


This problem was discovered in my boilerplate which uses your karma-config.

I ran script for tests on different PC: Win7, Win10, Node.js 6, Node.js 8, npm 3, npm 5. Results were same.


Logs

karma-remap-istanbul/examples/webpack

MacOS

> [email protected] test /Users/Valeriy/Projects/_github/karma-remap-istanbul/examples/webpack
> karma start

Hash: e0bdc8cc97632b01d813
Version: webpack 2.6.1
Time: 46ms
webpack: Compiled successfully.
webpack: Compiling...
ts-loader: Using [email protected] and /Users/Valeriy/Projects/_github/karma-remap-istanbul/examples/webpack/tsconfig.json
Hash: 43bf9646bfb07d28c8ce
Version: webpack 2.6.1
Time: 1322ms
            Asset    Size  Chunks                    Chunk Names
test/test.spec.ts  593 kB       0  [emitted]  [big]  test/test.spec.ts
chunk    {0} test/test.spec.ts (test/test.spec.ts) 214 kB [entry] [rendered]
    [0] ./~/chai/lib/chai/utils/flag.js 807 bytes {0} [built]
    [1] ./~/chai/lib/chai/config.js 1.46 kB {0} [built]
    [4] ./~/assertion-error/index.js 2.44 kB {0} [built]
   [11] ./~/chai/index.js 40 bytes {0} [built]
   [12] ./src/example.ts 3.78 kB {0} [built]
   [15] ./~/chai/lib/chai.js 1.28 kB {0} [built]
   [16] ./~/chai/lib/chai/assertion.js 3.79 kB {0} [built]
   [17] ./~/chai/lib/chai/core/assertions.js 51.8 kB {0} [built]
   [18] ./~/chai/lib/chai/interface/assert.js 40.9 kB {0} [built]
   [19] ./~/chai/lib/chai/interface/expect.js 770 bytes {0} [built]
   [20] ./~/chai/lib/chai/interface/should.js 5.67 kB {0} [built]
   [21] ./~/chai/lib/chai/utils/addChainableMethod.js 3.63 kB {0} [built]
   [29] ./~/chai/lib/chai/utils/index.js 1.71 kB {0} [built]
   [34] ./~/deep-eql/index.js 39 bytes {0} [built]
   [40] ./test/test.spec.ts 353 bytes {0} [built]
     + 28 hidden modules
webpack: Compiled successfully.
�[32m17 06 2017 14:42:15.011:INFO [karma]: �[39mKarma v1.7.0 server started at http://0.0.0.0:9876/
�[32m17 06 2017 14:42:15.013:INFO [launcher]: �[39mLaunching browser PhantomJS with unlimited concurrency
�[32m17 06 2017 14:42:15.031:INFO [launcher]: �[39mStarting browser PhantomJS
�[32m17 06 2017 14:42:16.241:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: �[39mConnected on socket 3QXq5mtuX9Q4THzMAAAA with id 26235617
.
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 1 of 1 SUCCESS (0.007 secs / 0.001 secs)

=============================== Coverage summary ===============================
Statements   : 85.71% ( 6/7 )
Branches     : 100% ( 0/0 )
Functions    : 66.67% ( 2/3 )
Lines        : 83.33% ( 5/6 )
================================================================================

Windows

> [email protected] test D:\Projects\karma-remap-istanbul\examples\webpack
> karma start

Hash: e0bdc8cc97632b01d813
Version: webpack 2.6.1
Time: 78ms
webpack: Compiled successfully.
webpack: Compiling...
ts-loader: Using [email protected] and D:\Projects\karma-remap-istanbul\examples\webpack\tsconfig.json
Hash: 009e53f1133f50e50e20
Version: webpack 2.6.1
Time: 2530ms
            Asset    Size  Chunks                    Chunk Names
test/test.spec.ts  583 kB       0  [emitted]  [big]  test/test.spec.ts
chunk    {0} test/test.spec.ts (test/test.spec.ts) 211 kB [entry] [rendered]
    [0] ./~/chai/lib/chai/utils/flag.js 807 bytes {0} [built]
    [1] ./~/chai/lib/chai/config.js 1.46 kB {0} [built]
    [4] ./~/assertion-error/index.js 2.44 kB {0} [built]
   [11] ./~/chai/index.js 40 bytes {0} [built]
   [12] ./src/example.ts 342 bytes {0} [built]
   [15] ./~/chai/lib/chai.js 1.28 kB {0} [built]
   [16] ./~/chai/lib/chai/assertion.js 3.79 kB {0} [built]
   [17] ./~/chai/lib/chai/core/assertions.js 51.8 kB {0} [built]
   [18] ./~/chai/lib/chai/interface/assert.js 40.9 kB {0} [built]
   [19] ./~/chai/lib/chai/interface/expect.js 770 bytes {0} [built]
   [20] ./~/chai/lib/chai/interface/should.js 5.67 kB {0} [built]
   [21] ./~/chai/lib/chai/utils/addChainableMethod.js 3.63 kB {0} [built]
   [29] ./~/chai/lib/chai/utils/index.js 1.71 kB {0} [built]
   [34] ./~/deep-eql/index.js 39 bytes {0} [built]
   [40] ./test/test.spec.ts 364 bytes {0} [built]
     + 28 hidden modules
webpack: Compiled successfully.
�[32m17 06 2017 14:38:55.191:INFO [karma]: �[39mKarma v1.7.0 server started at http://0.0.0.0:9876/
�[32m17 06 2017 14:38:55.195:INFO [launcher]: �[39mLaunching browser PhantomJS with unlimited concurrency
�[32m17 06 2017 14:38:55.227:INFO [launcher]: �[39mStarting browser PhantomJS
�[32m17 06 2017 14:38:58.530:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: �[39mConnected on socket uXQWAG8l6wfcZUdPAAAA with id 44955151
.
PhantomJS 2.1.1 (Windows 8 0.0.0): Executed 1 of 1 SUCCESS (0.012 secs / 0.003 secs)

=============================== Coverage summary ===============================
Statements   : 100% ( 0/0 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 0/0 )
Lines        : 100% ( 0/0 )
================================================================================

karma-remap-istanbul

MacOS

> [email protected] pretest /Users/Valeriy/Projects/_github/karma-remap-istanbul
> npm run lint


> [email protected] lint /Users/Valeriy/Projects/_github/karma-remap-istanbul
> xo


> [email protected] test /Users/Valeriy/Projects/_github/karma-remap-istanbul
> nyc mocha



  karma-remap-istanbul
    ✓ should generate a remapped coverage report (3649ms)
    ✓ should allow files to be excluded (2644ms)


  2 passing (6s)


=============================== Coverage summary ===============================
Statements   : 91.49% ( 43/47 )
Branches     : 75% ( 12/16 )
Functions    : 75% ( 9/12 )
Lines        : 91.49% ( 43/47 )
================================================================================

Windows

> [email protected] pretest D:\Projects\karma-remap-istanbul
> npm run lint


> [email protected] lint D:\Projects\karma-remap-istanbul
> xo


> [email protected] test D:\Projects\karma-remap-istanbul
> nyc mocha



  karma-remap-istanbul
    1) should generate a remapped coverage report
    2) should allow files to be excluded


  0 passing (8s)
  2 failing

  1) karma-remap-istanbul should generate a remapped coverage report:
     Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  

  2) karma-remap-istanbul should allow files to be excluded:

      Uncaught AssertionError: expected { Object (lines, statements, ...) } to deeply equal { Object (lines, statements, ...) }
      + expected - actual

           "skipped": 0
           "total": 0
         }
         "functions": {
      -    "covered": 0
      -    "pct": 100
      +    "covered": 2
      +    "pct": 66.67
           "skipped": 0
      -    "total": 0
      +    "total": 3
         }
         "lines": {
      -    "covered": 0
      -    "pct": 100
      +    "covered": 5
      +    "pct": 83.33
           "skipped": 0
      -    "total": 0
      +    "total": 6
         }
      -  "linesCovered": {}
      +  "linesCovered": {
      +    "1": 2
      +    "3": 1
      +    "4": 1
      +    "7": 1
      +    "8": 0
      +    "11": 1
      +  }
         "statements": {
      -    "covered": 0
      -    "pct": 100
      +    "covered": 6
      +    "pct": 85.71
           "skipped": 0
      -    "total": 0
      +    "total": 7
         }
       }
      
      at Assertion.assertEqual (node_modules\chai\lib\chai\core\assertions.js:485:19)
      at Assertion.ctx.(anonymous function) [as equal] (node_modules\chai\lib\chai\utils\addMethod.js:41:25)
      at Timeout.setTimeout [as _onTimeout] (test\index.spec.js:37:39)




=============================== Coverage summary ===============================
Statements   : 91.49% ( 43/47 )
Branches     : 68.75% ( 11/16 )
Functions    : 75% ( 9/12 )
Lines        : 91.49% ( 43/47 )
================================================================================

Do you have ideas how to solve this problem?

karma-remap-istanbul doesn't work with Node < 8 anymore

Hi all,

since source-map (as a sub-dependency of remap-istanbul) released a version 7 which dropped support for nodejs < 8 and the currently used version [email protected] does not lock the version of sourcemap inside, applications with nodejs < 8 are not working anymore.

Are there any plans to upgrade to a newer version of remap-istanbul to solve this issue?

Thx!

Error: Unable to find entry for

I have a running remap-istanbul setup working I'm trying to use karma-remap-istanbul to reduce boilerplate (calling posttest) but its not running

07 09 2016 18:17:12.537:ERROR [karma]: [Error: Unable to find entry for [src\app\border-component.ts]]
Error: Unable to find entry for [src\app\border-component.ts]

is there something more needed in the karma config?

browsers: ['Firefox'],
singleRun: true,

preprocessors: {
       "built/app/*.js": ["coverage"]
    },
   // Coverage reporter generates the coverage
   //reporters: ['progress', 'coverage'],
   reporters: ['progress', 'coverage', 'karma-remap-istanbul'],
   remapIstanbulReporter: {
         reports: {
             html: 'coverage'
         }
     }

am I missing something?

This was my previous karma.conf.js

   preprocessors: {
            "built/app/*.js": ["coverage"]
        },
        // Coverage reporter generates the coverage
        //reporters: ['progress', 'coverage'],
        reporters: ['progress', 'coverage', 'karma-remap-istanbul'],

        coverageReporter: {
            instrumenterOptions: {
                istanbul: { noCompact: true }
            },
            reporters:[
                {type: 'html', subdir: '.' },
                {type: 'json', subdir: '.', file: 'coverage-final.json'}
            ]
        },

        remapIstanbulReporter: {
            src: 'coverage/coverage-final.json',
            reports: {
                lcovonly: 'coverage/lcov.info',
                html: 'coverage'
            }
        }

with posttest call to remap-istanbul was working.

But now I get this error

Error: Unable to find entry for [src\app\border-component.ts]
at MemoryStore.Store.mix.get (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\store\memory.js:38:19)
at HtmlReport.Report.mix.writeDetailPage (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:411:67)
at C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:489:26
at SyncFileWriter.extend.writeFile (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\util\file-writer.js:57:9)
at FileWriter.extend.writeFile (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\util\file-writer.js:147:23)
at C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:488:24
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:482:23)
at C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:484:22
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:482:23)
at HtmlReport.Report.mix.writeReport (C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\istanbul\lib\report\html.js:566:14)
at C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\remap-istanbul\lib\writeReport.js:77:22
at C:\DEV\Angular2 Unit Tests Projects\ng2-test-seed-dan\node_modules\amdefine\amdefine.js:125:34
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)

Expand on readme details

"You will need to either install karma-coverage and configure it as a preprocessor for your transpiled modules under test or instrument the modules under test as part of your build process. If the latter option is chosen, the coverage statistics will need to be stored at the coverage global variable (istanbul's default) or karma will not transmit them back to the runner."

Can you find the time to better describe what this means in plain English? :)
As written, someone like me who is relatively new to Angular2 and Typescript, will get lost with that statement.

TypeError: Cannot read property 'text' of undefined

All in a sudden, it's giving these errors. It was working fine before. Any idea? Thanks.

18 04 2016 21:59:49.177:ERROR [karma]: [TypeError: Cannot read property 'text' of undefined]
TypeError: Cannot read property 'text' of undefined
at node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:286:59
at Array.forEach (native)
at annotateBranches (node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:255:30)
at HtmlReport.Report.mix.writeDetailPage (node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:426:9)
at node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:489:26
at SyncFileWriter.extend.writeFile (node_modules/remap-istanbul/node_modules/istanbul/lib/util/file-writer.js:57:9)
at FileWriter.extend.writeFile (node_modules/remap-istanbul/node_modules/istanbul/lib/util/file-writer.js:147:23)
at node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:488:24
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:482:23)
at node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:484:22
at Array.forEach (native)
at HtmlReport.Report.mix.writeFiles (node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:482:23)
at HtmlReport.Report.mix.writeReport (node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:566:14)
at node_modules/remap-istanbul/lib/writeReport.js:61:22
at node_modules/amdefine/amdefine.js:125:34
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

karma-remap-istanbul with Quickstart angular 2 configuration shows application output on browser

I have taken the latest Angular 2 Quickstart clone. I have updated the karma.config.js file according to the steps mentioned. My test cases run and the coverage report is generated in Typescript which is great!

The Chrome browser shows the default page of the application when test cases are run as follows:


capture

karma.config.js file:


module.exports = function (config) {

  var appBase = 'app/';      // transpiled app JS and map files
  var appSrcBase = 'app/';      // app source TS files
  var appAssets = '/base/app/'; // component assets fetched by Angular's compiler

  // Testing helpers (optional) are conventionally in a folder called `testing`
  var testingBase = 'testing/'; // transpiled test JS and map files
  var testingSrcBase = 'testing/'; // test source TS files

  config.set({
    basePath: '',
    frameworks: ['jasmine'],

    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-remap-istanbul'),
      require('karma-coverage')
    ],

    client: {
      builtPaths: [appBase, testingBase], // add more spec base paths as needed
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },

    customLaunchers: {
      // From the CLI. Not used here but interesting
      // chrome setup for travis CI using chromium
      Chrome_travis_ci: {
        base: 'Chrome',
        flags: ['--no-sandbox']
      }
    },

    files: [
      // System.js for module loading
      'node_modules/systemjs/dist/system.src.js',

      // Polyfills
      'node_modules/core-js/client/shim.js',
      'node_modules/reflect-metadata/Reflect.js',

      // zone.js
      'node_modules/zone.js/dist/zone.js',
      'node_modules/zone.js/dist/long-stack-trace-zone.js',
      'node_modules/zone.js/dist/proxy.js',
      'node_modules/zone.js/dist/sync-test.js',
      'node_modules/zone.js/dist/jasmine-patch.js',
      'node_modules/zone.js/dist/async-test.js',
      'node_modules/zone.js/dist/fake-async-test.js',

      // RxJs
      { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },

      // Paths loaded via module imports:
      // Angular itself
      { pattern: 'node_modules/@angular/**/*.js', included: false, watched: false },
      { pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false },

      { pattern: 'systemjs.config.js', included: false, watched: false },
      { pattern: 'systemjs.config.extras.js', included: false, watched: false },
      'karma-test-shim.js', // optionally extend SystemJS mapping e.g., with barrels

      // transpiled application & spec code paths loaded via module imports
      { pattern: appBase + '**/*.js', included: false, watched: true },
      { pattern: testingBase + '**/*.js', included: false, watched: true },


      // Asset (HTML & CSS) paths loaded via Angular's component compiler
      // (these paths need to be rewritten, see proxies section)
      { pattern: appBase + '**/*.html', included: false, watched: true },
      { pattern: appBase + '**/*.css', included: false, watched: true },

      // Paths for debugging with source maps in dev tools
      { pattern: appSrcBase + '**/*.ts', included: false, watched: false },
      { pattern: appBase + '**/*.js.map', included: false, watched: false },
      { pattern: testingSrcBase + '**/*.ts', included: false, watched: false },
      { pattern: testingBase + '**/*.js.map', included: false, watched: false }
    ],

    // Proxied base paths for loading assets
    proxies: {
      // required for component assets fetched by Angular's compiler
      "/app/": appAssets
    },

    exclude: [],

    preprocessors: {
      'app/**/!(*spec).js': ['coverage']
    },
    //    reporters: ['progress', 'kjhtml'],

    reporters: ['progress', 'coverage', 'karma-remap-istanbul'],
    remapIstanbulReporter: {
      reports: {
        html: 'coverage'
      }
    },

    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  })
}

Why does the application output show?

Report output directory

I am trying show the output source files with coverage in same folder as karma-coverage folder. But I don't see an option to define the destination folder for output. Need suggestion on this. Iam doing this.

coverageReporter: {
       reporters: [
       {
      type: 'json',
      subdir: '.', 
      file: 'coverage-final.json'
    },
    { type : 'html' },
    { type : 'text' }
  ],
  dir : 'coverage',
  includeAllSources: true,
  check: {
    global: {
      statements: 50,
      branches: 50,
      functions: 50,
      lines: 50
    },
    each: {
      statements: 50,
      branches: 50,
      functions: 50,
      lines: 50
    }
  }
},
remapIstanbulReporter: {
  src: 'coverage/coverage-final.json',
  reports: {
    html: 'coverage'
  },
  dest : '/coverage-source',
  timeoutNotCreated: 1000,
  timeoutNoMoreFiles: 1000
}

Error: Unable to find entry

I added configuration like described here, and after running i get the following error.
[Error: Unable to find entry for [dev/app/content-types.ts]]

When executing remap-istanbul through gulp everything works fine.

I tested the following setups, with the same result:

        coverageReporter: {
            type: 'json',
            subdir: '.'
        },

        remapIstanbulReporter: {
            src: 'coverage/coverage-final.json',
            reports: {
                html: 'coverage'
            },
            dest : './coverage-source'
        },

and simply

      remapIstanbulReporter: {
          reports: {
              html: 'coverage'
          }
      },

Support basePath option

If you put your compiled files in a different folder than your source files, you need to set the base path to the original location so remap-istanbul can find the files.

include all files in coverage?

All the files are not included in the coverage report. Only files having corresponding .spec files are shows in the report.

includeAllSources: true
of karma-coverage library does not work.


 remapIstanbulReporter: {
      reports: {
        html: 'coverage'
      },
      includeAllSources: true
    },

Cannot read properties of null (reading 'split')

My lcov.info remapping worked just fine, but when I tried to include an HTML report, I got this error (paths shortened for readability):

ERROR [reporter.remap-istanbul]: �[39mTypeError: Cannot read properties of null (reading 'split')
    at HtmlReport.writeDetailPage (.../[email protected]/node_modules/istanbul/lib/report/html.js:412:31)
    at .../[email protected]/node_modules/istanbul/lib/report/html.js:489:26

Not sure if the error is in istanbul or in this library due to some configuration with istanbul though

EACCES: permission denied, open '/index.html'

I'm trying to use this plugin according to the example on karma-coverage, however after the coverage is created successfully (but not remapped yet), the plugin throws this error:

{ [Error: EACCES: permission denied, open '/index.html']
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/index.html' }
Error: EACCES: permission denied, open '/index.html'
    at Error (native)
    at Object.fs.openSync (fs.js:549:18)
    at Object.fs.writeFileSync (fs.js:1156:15)
    at SyncFileWriter.extend.writeFile (/home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/util/file-writer.js:58:12)
    at FileWriter.extend.writeFile (/home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/util/file-writer.js:147:23)
    at HtmlReport.Report.mix.writeFiles (/home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:479:16)
    at /home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:484:22
    at Array.forEach (native)
    at HtmlReport.Report.mix.writeFiles (/home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:482:23)
    at HtmlReport.Report.mix.writeReport (/home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/istanbul/lib/report/html.js:566:14)
    at /home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/lib/writeReport.js:77:22
    at /home/ubuntu/workspace/node_modules/karma-remap-istanbul/node_modules/remap-istanbul/node_modules/amdefine/amdefine.js:125:34
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)

It seems to want to open the default browser, which is not possible as I'm developing in a cloud IDE (Cloud9). Is it possible to turn this feature off?

Thanks

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

Hello!

On my TSX project after ~60 tests I always get this error under UNIX and Win7:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

When I look at task manager, I see that node.exe takes about 1.9GB of ROM at this moment. I think that it happens because of large sourcemaps. The project is small (about 30 files). May be there is a way to preprocess and/or process files not all at one moment and keep everything in memory, but 5 or 10 files?

Here is my karma config

const webpack = require('webpack');
const autoprefixer = require('autoprefixer');

module.exports = (config) => {
config.set({
browsers: ['Chrome'],
singleRun: true,
concurrency: Infinity,
autoWatch: false,
frameworks: ['jasmine'],
plugins: [
'karma-sourcemap-loader',
'karma-webpack',
'karma-jasmine',
'karma-remap-istanbul',
'karma-coverage',
'karma-chrome-launcher',
'karma-spec-reporter'
],

files: [
  'node_modules/babel-polyfill/dist/polyfill.js',
  'src/**/*.spec.*'
],

preprocessors: {
  'src/**/*.spec.*': ['webpack', 'sourcemap'],
},

reporters: ['karma-remap-istanbul', 'spec'],

webpackMiddleware: {
  stats: 'errors-only',
  noInfo: true,
},

remapIstanbulReporter: {
  src: 'coverage/coverage-final.json',
  reports: {
    lcovonly: 'coverage/lcov.info',
    html: 'coverage/report',
    'text-summary': '',
  },
  fixWebpackSourcePaths: true,
},

autoWatchByDelay: 3000,

level: 'debug',

webpack: {
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.tsx$/,
        loader: 'awesome-typescript-loader',
      }, {
        test: /\.tsx$/,
        loader: 'istanbul-instrumenter-loader',
        enforce: 'post',
        options: {
          esModules: true,
        },
      },
      {
        test: /\.css$/,
        use: [
          { loader: 'style-loader' },
          { loader: 'css-loader' },
          {
            loader: 'postcss-loader',
            options: {
              plugins: () => [autoprefixer('ie >= 11')],
            },
          }
        ],
      },
      {
        test: /\.svg|ico|png|gif|jpg|scss|eot|ttf|woff|woff2($|\?)/,
        loader: 'null-loader',
      }
    ],
  },
  resolve: {
    extensions: ['.js', '.ts', '.tsx', '.css', '.scss', '.png'],
  },
  plugins: [
    new webpack.SourceMapDevToolPlugin({
      filename: null,
      test: /\.tsx($|\?)/i,
    })
  ],
  externals: {
    cheerio: 'window',
    'react/addons': true,
    'react/lib/ExecutionEnvironment': true,
    'react/lib/ReactContext': true,
  },
},

});
};

Doubled error message

Part of the karma.config:

reporters: ["progress", "coverage", "karma-remap-istanbul"],
SlimerJS App component should build without a problem FAILED
        Failed: fixture.nativeElement.innerText is undefined
        @build/js/components/app/components/app/app.component.spec.ts:25:16 <- build/js/components/app/app.component.spec.js:22:13
SlimerJS: Executed 8 of 14 (1 FAILED) (skipped 1) (0 secs / 0.268 secs)
SlimerJS App component should build without a problem FAILED
        Failed: fixture.nativeElement.innerText is undefined
SlimerJS: Executed 8 of 14 (1 FAILED) (skipped 6) (0.283 secs / 0.268 secs)

If I will remove karma-remap-istanbul from reporters, the result will be:

SlimerJS App component should build without a problem FAILED
        Failed: fixture.nativeElement.innerText is undefined
        @build/js/components/app/components/app/app.component.spec.ts:25:16 <- build/js/components/app/app.component.spec.js:22:13
SlimerJS: Executed 8 of 14 (1 FAILED) (skipped 6) (0.315 secs / 0.263 secs)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.