Tests: Refactor lib/plugins/aws/deploy/lib/checkForChanges.test.js
#8.886 geöffnet am 3. Feb. 2021
Beschreibung
Most of the tests that currently cover core functionalities depend heavily on (and sometimes test) internal implementation characteristics. While they should be testing whether given implementation produces desired outcome (treating its implementation more as a black box).
Current state of things is problematic for eventual internal improvements and refactors which occasionally we want to introduce, as in most of such cases proposed improvements need to be accompanied with counterproductive numerous updates to tests which are covering otherwise not altered functionalities .
At some point we've introduced a new (black box based) way of testing the internals. It's through runServerless utlity, which allows us create natural (as in real world) serverless instance, and inspect the produced outcome for chosen command. More details here: https://github.com/serverless/serverless/tree/master/test#unit-tests
This is issue is about refactoring test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js to runServerless based variant.
To make refactor relatively easy:
- Spec for new tests is fully defined and is already committed in. It's in scope of this describe block: https://github.com/serverless/serverless/blob/7c998e03ca104948c6c2673c9fee6992689219df/test/unit/lib/plugins/aws/deploy/lib/checkForChanges.test.js#L943-L1564
- Each test slot indicates which test it is about to replace
runServerlessruns are already preconfigured, with comments indicating where blank dots need to be filled
For every refactored test, the old test should be removed
Refactor can be submitted with one PR, but partial refactors that cover some of tests are also very welcome!