Tag: Unit tests


Cypress is a fantastic front end testing tool but has one major limitation. I already blogged about it a while ago. The limitation is that it runs all tests within an iframe. This iframe approach makes sense, as it allows the tool to show the running tests and the page in one view.


Back in April 2017, I wrote about how you could write unit tests for SharePoint Framework components. This was created by a combination of the dependencies provides by SharePoint Framework itself and enzyme (JavaScript Testing utilities for React). Info: you can read more about writing unit tests for SharePoint Framework components here: Writing unit tests for your SharePoint Framework components.


The reason you probably read this post is that you already wrote some unit tests for SharePoint Framework projects and you stumble upon a problem and want to debug one of your unit-tests. Apparently, the process is not so easy as linking your debugger to the gulp test task. There is a bit more plumbing involved to get a good experience.


In one of the previous posts I showed that since SharePoint Framework version 1.2.0, code coverage reports were added. When you run the gulp test task, it will execute the tests, and generate a code coverage report which you can find under the temp/coverage/js project folder. Read more about this in the following article: SharePoint Framework code coverage reports for unit-tests


A while ago I wrote an article about writing unit tests for your SharePoint Framework components. One of the missing things was a code coverage report to check how well you unit-test your codebase. Read more: Writing unit-tests for your SharePoint Framework components Apparently, with the v1.2.0 of SharePoint Framework they added a tool called Istanbul which can generate such reports.


Last week I published a sample project on GitHub which shows how you can test your SharePoint Framework components with some predefined unit tests. Info: here is a link to the repo - https://github.com/estruyf/spfx-testing-wp The current sample is created with React. The unit tests are created only to test the actual component instead of the main web part.