javascriptangularunit-testingdeploymentdescribe

How to check that during unit testing with ng-test, fdescribe() and fit() are never called?


Simple scenario, angular, unit testing and continuous deployment. What can happen is that a developer finishes the unit test related to a component. During development time the developer uses the functions fdescribe() or fit() just to run those specific tests.

In a moment of distraction the developer commits and pushes and deploy is done on production, but fdescribe() or fit() was forgotten in the code.

Tests are not failing, but this brings a bad scenario in, basically all the regular tests are not running, but the traffic-light says GO and all deploy is done.

Is it possible to check that in the all unit tests any fdescribe() or fit() are called?


Solution

  • You can set a pre-commit Git Hook that will check that fdescribe() and fit() (and any code you don't want to be committed) aren't present in your test files.

    Here's an example code you can find on githooks.

    In your case, I think this pre-commit code could be very useful given that it will check all files in staging area that are added, modified or renamed but not deletions.