Checks
Testing checks
For more complex checks you may want to make sure that your validation and fix logic is what you would expect it to be.
We recommend using mock-fs along with our defineTestCheck utility to mock the file system. This combination will test your checks end-to-end to ensure that your checks never create unexpected changes.
Example check
Here’s an example of a check that reads a file from disk, has dynamically returned messages, and auto-fix functionality.
ensure-license.ts
Example test
We can test that the check accurately reads the file, returns the correct validation result, and that the auto-fix function correctly updates the file on disk.
ensure-license.test.ts
Was this page helpful?