How do you use Istanbul Code Coverage with transpiled Typescript?

后端 未结 5 1172
耶瑟儿~
耶瑟儿~ 2021-02-01 14:11

I\'ve been reading articles on this all morning trying to get my environment setup correctly. But for some reason I\'m not getting it. My setup-

/app
    ... sou         


        
5条回答
  •  灰色年华
    2021-02-01 14:48

    As blakeembrey mentioned. Istanbul 1.x handles it well.

    Below an example of pure npm script that does it with Jasmine.

    See https://github.com/Izhaki/Typescript-Jasmine-Istanbul-Boilerplate.

    package.json (the relevant stuff)

    {
      "scripts": {
        "postinstall": "typings install dt~jasmine --save --global",
        "test": "ts-node node_modules/.bin/jasmine JASMINE_CONFIG_PATH=jasmine.json",
        "test:coverage": "ts-node node_modules/istanbul/lib/cli.js cover -e .ts  -x \"*.d.ts\" -x \"*.spec.ts\" node_modules/jasmine/bin/jasmine.js -- JASMINE_CONFIG_PATH=jasmine.json"
      },
      "devDependencies": {
        "istanbul": "^1.1.0-alpha.1",
        "jasmine": "^2.4.1",
        "ts-node": "^0.9.3",
        "typescript": "^1.8.10",
        "typings": "^1.3.1"
      },
    }
    

    Output

    image

提交回复
热议问题