Let's say i want to unit test a function in typescript. This function use an "option" type (object) parameter with a complex shape.
interface option {
param1 : string
param2 : number
param3 : {
param4 : string
param5 : boolean
}
.
.
.
param15 : string
}
const functionToTest = (opt:option)=>{
...do stuff with option
}
Now let say i want to write a unit test that mimic the correct behaviour of functionToTest when param1 change, ignoring the other parameter that have no influence on the result.
It's my understanding that to make my test more resilient, i can just write in plain JS
const option1 = {
param1 : "foo"
}
and do my testing
expect(functionToTest(option1)).to.be.true;
However, if i write my test with typescript, i will have to write a full option1 object with all of the interface (dummy) members, althought most will be ignored, and it will divert the reader from the true goal of the test.
Are there workarounds around this or something i should change in my thinking ?