Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Add sourcemap support for coverage by using remap-istanbul #23

Merged
merged 1 commit into from
Jul 12, 2016

Conversation

ThaNarie
Copy link
Member

Added remap-istanbul and all supporting karma plugins to correctly
remap the coverage results back to their TypeScript source.

Since all generations happens in memory by Webpack, we needed inline
sourcemap support, provided by the Karma plugins, the Webpack devtool
setting, and the webpack typescript loader.

The normal ts-loader doesn't support inline sourcemaps, so we switched
to awesome-typescript-loader. We created a new tsconfig.test.json
that is the same as the normal tsconfig.json but enables inline
sourcemaps by adding "inlineSourceMap": true.

The webpack dist builds have also switched to awesome-typescript-loader
to keep the configuration consistent.

To make the awesome-typescript-loader correctly work with const enums,
we needed to enable preserveConstEnums property in the tsconfig.json.

We also switched he test/index.js to index.ts and included
webpack-env in the typings.json so all wepack requires work in
TypeScript.

To have correct coverage reports consisting of all the source files,
we've added a Dummy.ts file in the src/ folder that is not
referenced by any tests, but must show up in the coverage results.
If this is not the case, we know our test setup is incorrect.

re #15

Added remap-istanbul and all supporting karma plugins to correctly
remap the coverage results back to their TypeScript source.

Since all generations happens in memory by Webpack, we needed inline
sourcemap support, provided by the Karma plugins, the Webpack devtool
setting, and the webpack typescript loader.

The normal `ts-loader` doesn't support inline sourcemaps, so we switched
to `awesome-typescript-loader`. We created a new `tsconfig.test.json`
that is the same as the normal `tsconfig.json` but enables inline
sourcemaps by adding `"inlineSourceMap": true`.

The webpack dist builds have also switched to `awesome-typescript-loader`
to keep the configuration consistent.

To make the `awesome-typescript-loader` correctly work with const enums,
we needed to enable `preserveConstEnums` property in the `tsconfig.json`.

We also switched he `test/index.js` to `index.ts` and included
`webpack-env` in the `typings.json` so all wepack requires work in
TypeScript.

To have correct coverage reports consisting of _all_ the source files,
we've added a `Dummy.ts` file in the `src/` folder that is not
referenced by any tests, but must show up in the coverage results.
If this is not the case, we know our test setup is incorrect.

re #15
@coveralls
Copy link

coveralls commented Jul 11, 2016

Coverage Status

Changes Unknown when pulling 97d348e on feature/remap-istanbul into * on master*.

@@ -40,7 +40,10 @@ module.exports = function()
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts'
loader: 'awesome-typescript-loader',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind changing this to awesome-typescript-loader, but if we use a separate webpack config for test we could theoretically still use the 'default' ts-loader here. Maybe we should test the performance of the loaders when we have a bigger test project in skeleton. For now though, let's just use the same loader for both.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the idea was to use the same loader for both tests and distribution builds, so we know that if the tests can correctly run the generated code, the distribution builds should be fine as well.
Still, we use the normal TypeScript compiler for npm builds, so that's a difference we cannot overcome. (The 'default ts-loader is still different than the standalone tsc, so we will never get rid of that difference)

@ThaNarie ThaNarie merged commit 7f7c43f into master Jul 12, 2016
@ThaNarie ThaNarie deleted the feature/remap-istanbul branch July 12, 2016 18:56
flut1 added a commit to flut1/knockout-validator that referenced this pull request Jul 18, 2016
Added fixes and improvements to unit testing from the
seng-boilerplate repo:
mediamonks/seng-boilerplate#28
mediamonks/seng-boilerplate#27
mediamonks/seng-boilerplate#23

Replaced some mediamonks/seng boilerplate names to
knockout-validator equivalents.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants