#Unit Testing Declarative Code

7 messages · Page 1 of 1 (latest)

summer mica
#

Hey all, I'm new to nest, and only slightly less new to this style of code where almost everything is declarative --

How do I unit test a module, a model, a resolver, a controller, which have zero or near-zero business logic, without just rewriting the whole thing in my test file and asserting the configuration?

empty robin
#

First ask yourself "If I'm unit testing this file, what am I testing about it?" If you're testing it to generate the coverage, or to ensure the decorators are applied, you're testing it for the wrong reason

summer mica
#

Obviously... so what DO I test about it? 90% of my app is declarative, there are just a couple lines of logic in my per-feature services... I don't think only testing those counts much for confidence in the overall application

empty robin
#

Then you should probably try e2e testing over unit testing. Send in HTTP requests and assert their responses

summer mica
#

Sense. Can jest(etc) generate a coverage map from e2e tests same as it can from unit?

empty robin
#

With some configuration, yes, it's possible

summer mica
#

Will play with it. Thanks much!