Theo's Typesafe CultTTC
Theo's Typesafe Cult12mo ago
11 replies
Huilen

what should i unit test and what shouldn't I?

Hi, a dev new to unit testing here! I'm wondering if, in a typescript project, should i test functions against runtime or not.

example:
function iReceiveAString(arg:string){
  //
}

// should I test this?
expect(iReceiveAstring(1234)).toThrow()


should i test that functions throw errors if arguments do not match what is typed? for me, i think that it isnt useful, since as the project has typescript, therefore a type checking script when compiling, those kind of errors will appear there if not shown by the linter before.

what do you think? what is the "standard" for this? would love some advice!
Was this page helpful?