In ES5 we can write like this:
function(a){
/* istanbul ignore next */
a = a || 123;
}
how to ignore In ES6?
function(a = 123 ){
}
I tried this:
function(/* istanbul ignore next */a = 123 ){
}
but it's not working.
This works for me:
function(
/* istanbul ignore next */
a = 123
){
}
When using TypeScript, this was a bit harder to solve since the types must match. I was able to get it to work by passing in undefined
for each parameter. For example...
function testMe(a:SomeType = { foo: 'bar' }, b:AnotherType = { bar: 'baz'}) {
return a * b;
}
describe('Branch Coverage', () => {
it('should pass branch coverage', () => {
expect(testMe(undefined, undefined);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With