Share via


Clean up your testing sites with SP Chrome Extension and sp-pnp-js

If you are using the testing features of sp-pnp-js you know it creates a sub web for each test run, and if you are doing many tests these can quickly collect. We purposefully don't delete them in case you need to investigate something - but after they are used they can be deleted. This can be tedious through the UI so I wanted to share a technique I use with the Chrome SP Editor extension. You can install it following the link on the project homepage. The editor includes the sp-pnp-js library and a slick editor window. Paste the below script in the window, hit "Ctrl+d" to run it and your sub sites will be cleaned up.

Note: this script deletes all sub sites so ensure you are only cleaning up the sites you want. I use a dedicated test site collection to ensure nothing important can be affected by testing and recommend you follow that practice.