Trying to test to make sure that a typed variable can only be assigned certain values. Is there a way to use jest to throw an error if an invalid value is assigned, without typescript preventing the tests from running and throwing an error before tests run?
In class constructor:
defaultValue: string | null
In test:
expect(() => instance.defaultValue = 100).toThrow()
I expect that the test should run and acknowledge that this does throw an error, but the error is thrown before the test runs, preventing all tests from running.
Aucun commentaire:
Enregistrer un commentaire