Struggling with navigating TS (amazing) static typing to generate invalid data for a negative test scenario.
I am currently working on resolving an issue where the client may pass invalid JSON (double quotes within the value). I believe I have fixed the issue, but I want to confirm this through a unit test.
Therefore, I need to input some invalid JSON into a method to confirm that it rejects bad data.
postId: "1234",
comment: "an invalid "comment"
};
Can anyone suggest a method to construct the test data that mimics the invalid JSON?
//ts-ignore
doesn't seem to be providing the solution I need. I must be overlooking something obvious. TIA
Play around with it at https://codesandbox.io/s/competent-glitter-q8jn7