SPFx and TDD

%3CLINGO-SUB%20id%3D%22lingo-sub-676576%22%20slang%3D%22en-US%22%3ESPFx%20and%20TDD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676576%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEvery%20couple%20of%20years%20there's%20a%20SharePoint%20developer%20who%20publishes%20a%20few%20posts%20talking%20about%20a%20unit%20testing%20framework%20working%20with%20SPFx.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhile%20I%20can%20absolutely%20understand%20the%20value%20of%20unit%20tests%20in%20large%20code%20bases%20or%20in%20complex%20solutions%2C%20I%20do%20struggle%20to%20justify%20the%20overhead%20when%20it%20comes%20to%20SharePoint%20components.%3C%2FP%3E%3CP%3EThese%20are%2C%20at%20least%20in%20our%20context%2C%20a%20series%20of%20single%20purpose%20independent%20components%2C%20where%20the%20core%20of%20the%20effort%20is%20on%20the%20UI%20layer.%3CBR%20%2F%3EThe%20overhead%20of%20mocking%20up%20all%20the%20different%20lists%20and%20libraries%20that%20are%20often%20part%20of%20the%20solution%20is%20quite%20significant%2C%20and%20as%20those%20instances%20change%20quite%20rapidly%20as%20we%20put%20them%20in%20the%20hands%20of%20the%20user%2C%20keeping%20all%20tests%20up%20to%20date%2C%20passing%20and%20relevant%20quickly%20adds%20up.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20really%20worth%20the%20investment%20of%20time%20in%20teaching%20the%20team%20how%20to%20use%26nbsp%3Ba%20testing%20framework%2C%20integrating%20it%20on%20our%20practices%2C%20and%20accepting%20the%20overhead%20on%20every%20small%20piece%20of%20work%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20those%20of%20you%20out%20there%20using%20SPFx%20in%20anger%2C%20are%20you%20using%20TDD%2C%20or%20planning%20to%20use%20it%3F%3CBR%20%2F%3EDo%20you%20think%20it%20brings%20to%20SharePoint%20development%20the%20same%20level%20of%20benefits%20that%20it%20brings%20to%20full%20custom%20developed%20apps%3F%20Any%20particular%20framework%20that%20gels%20well%20with%20SPFx%20that%20you%20think%20I%20should%20absolutely%20be%20looking%20into%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20your%20help%20and%20advice.%3C%2FP%3E%3CP%3ECheers%2C%3CBR%20%2F%3EJC%26nbsp%3B%3CBR%20%2F%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-677611%22%20slang%3D%22en-US%22%3ERe%3A%20SPFx%20and%20TDD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-677611%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5454%22%20target%3D%22_blank%22%3E%40Jorge%20Carvalho%3C%2FA%3E%26nbsp%3BThe%20age%20old%20question%20and%20something%20that%20not%20enough%20people%20do%20in%20my%20opinion%20%3A)%3C%2Fimg%3E%20It's%20one%20of%20those%20%22depends%22%20scenarios%2C%20where%2C%20if%20you%20are%20okay%20with%20not%20Unit%20Testing%2C%20that's%20entire%20up%20to%20your%20development%20team%20and%20practices.%20It's%20valid%20to%20feel%20there%20is%20a%20bit%20of%20overhead%20because%20of%20the%20upfront%20work%20to%20do%20the%20unit%20tests.%20I%20think%20you'll%20see%20more%20ISVs%20or%20businesses%20with%20a%20product%20that%20will%20heavily%20use%20Unit%20Tests.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20like%20the%20benefits%20of%20Unit%20tests%2C%20and%20if%20you%20are%20going%20to%20do%20unit%20tests%2C%20look%20into%20using%20JEST.%20I'm%20sure%20you've%20seen%20them%2C%20but%20Elio%20has%20some%20great%20posts%20on%20this.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.eliostruyf.com%2Fwriting-unit-test-for-your-sharepoint-framework-components%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.eliostruyf.com%2Fwriting-unit-test-for-your-sharepoint-framework-components%2F%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.eliostruyf.com%2Fsharepoint-framework-unit-tests-with-jest%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.eliostruyf.com%2Fsharepoint-framework-unit-tests-with-jest%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-680370%22%20slang%3D%22en-US%22%3ERe%3A%20SPFx%20and%20TDD%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-680370%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F39836%22%20target%3D%22_blank%22%3E%40Beau%20Cameron%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20agree%20that%20if%20you%20have%20a%20large%20complex%20product%2C%20you%20definitely%20get%20value%20from%20a%20solid%20test%20harness.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20if%20you're%20building%20small%20independent%20apps%2C%20with%20very%20specific%20purposes%2C%20often%20tactical%20disposable%20solutions%2C%20the%20impact%20on%20cost%20and%20time%20to%20release%20are%20harder%20to%20justify.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELeaning%20towards%20the%20simpler%20approach%20at%20the%20moment%20but%20I%20think%20I'll%20have%20to%20argue%20with%20myself%20on%20this%20one%20a%20little%20longer.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi,

 

Every couple of years there's a SharePoint developer who publishes a few posts talking about a unit testing framework working with SPFx.

 

While I can absolutely understand the value of unit tests in large code bases or in complex solutions, I do struggle to justify the overhead when it comes to SharePoint components.

These are, at least in our context, a series of single purpose independent components, where the core of the effort is on the UI layer.
The overhead of mocking up all the different lists and libraries that are often part of the solution is quite significant, and as those instances change quite rapidly as we put them in the hands of the user, keeping all tests up to date, passing and relevant quickly adds up. 

 

Is it really worth the investment of time in teaching the team how to use a testing framework, integrating it on our practices, and accepting the overhead on every small piece of work?

 

For those of you out there using SPFx in anger, are you using TDD, or planning to use it?
Do you think it brings to SharePoint development the same level of benefits that it brings to full custom developed apps? Any particular framework that gels well with SPFx that you think I should absolutely be looking into?

 

Thanks in advance for your help and advice.

Cheers,
JC 
 

2 Replies
Highlighted

@Jorge Carvalho The age old question and something that not enough people do in my opinion :) It's one of those "depends" scenarios, where, if you are okay with not Unit Testing, that's entire up to your development team and practices. It's valid to feel there is a bit of overhead because of the upfront work to do the unit tests. I think you'll see more ISVs or businesses with a product that will heavily use Unit Tests.

I like the benefits of Unit tests, and if you are going to do unit tests, look into using JEST. I'm sure you've seen them, but Elio has some great posts on this. 

https://www.eliostruyf.com/writing-unit-test-for-your-sharepoint-framework-components/
https://www.eliostruyf.com/sharepoint-framework-unit-tests-with-jest/




Highlighted

Thanks @Beau Cameron 

 

I agree that if you have a large complex product, you definitely get value from a solid test harness.

 

But if you're building small independent apps, with very specific purposes, often tactical disposable solutions, the impact on cost and time to release are harder to justify.

 

Leaning towards the simpler approach at the moment but I think I'll have to argue with myself on this one a little longer.