Skip to content

Instantly share code, notes, and snippets.

@DanteDeRuwe
Last active April 28, 2022 14:11
Show Gist options
  • Save DanteDeRuwe/97fdaf252dc7540a7af8d21f436f512d to your computer and use it in GitHub Desktop.
Save DanteDeRuwe/97fdaf252dc7540a7af8d21f436f512d to your computer and use it in GitHub Desktop.
Enable logging in karma.conf.js
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true,
},
jasmine.getEnv().addReporter({
specStarted: (result) => {
(jasmine as any).currentTest = result;
},
specDone: (result) => {
(jasmine as any).currentTest = result;
},
});
afterEach(() => {
const pass =
(jasmine as any).currentTest.failedExpectations.length === 0;
console[pass ? 'log' : 'error'](`[${pass ? 'pass' : 'FAIL'}]`, {
name: (jasmine as any).currentTest,
//... extra params to log
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment