Jasmine Typescript Console Reporter
![license](https://img.shields.io/badge/license-MIT-blue.svg)
A Jasmine Console Reporter that remaps Typescript files. This will use source maps to remap the error stack file paths and line numbers to the source typescript files.
Preview
![preview](https://github.com/SeanSobey/JasmineTSConsoleReporter/raw/HEAD/./images/preview.png)
Installation
npm i jasmine-ts-console-reporter
Usage
Create a helper file for jasmine, eg specs/helpers.js
const TSConsoleReporter = require('jasmine-ts-console-reporter');
jasmine.getEnv().clearReporters();
jasmine.getEnv().addReporter(new TSConsoleReporter());
Load the helper file in Jasmine, eg on node jasmine.json:
{
"helpers": [
"specs/helpers.js",
]
}
Custom sourceMapProvider
For more intricate usage scenarios, like using istanbul where the sourcemaps for instumented files are held in memory, you can locate the sourcemaps via a callback:
new TSConsoleReporter({
sourceMapProvider: (fileName) => {
const map = fetchMySourceMap(fileName);
return map ? { map } : null;
}
});
You can provide additional ignore patterns for the stack trace (on top the built in exclusion of jasmine sources), this is useful for when you are using test frameworks that show up in the stack trace like typemoq.
new TSConsoleReporter({
stackFilterIgnore: /node_modules\\typemoq/
});
new TSConsoleReporter({
stackFilterIgnore: '**/node_modules/typemoq/**'
});
Custom message filter
You can provide additional filtering for the error message, this is useful for when you want to limit or decorate the message output in some way.
new TSConsoleReporter({
messageFilter: (message) => message.split('\n')[0]
});