|
|
|
|
|
by shados
3609 days ago
|
|
You really shouldn't have a "trivial" test that a type system like TypeScript makes redundant, when doing pure JavaScript either. If you have a function, eg: (a, b) => a + b
The only thing TypeScript will help you enforce here is that a and b should be numbers, and the function should return a number. Except, the test for this will be something such: "given 10 and 21, return 31". So you're testing the return type already. TypeScript will ensure that you never pass a string to a or b, for sure, but you should not have a test for that (unless you literred your code with type guards and wanted to test those. Don't do that). Now, unless the function above is your final, public API (where TypeScript/Flow will have the biggest bang for the buck and have the most value add), you're probably calling that function somewhere. That somewhere will be tested too, and the full test harness will make sure strings never end up there. You'll never actually need to write a test: "Make sure this is a string", and the only vulnerable area is the top level API, and that is a responsibility of the caller. |
|