Roots Discourse

Should I do unit tests to jQuery?

I am very interested in unit testing and I was wondering if I should unit test jQuery as in my project: https://github.com/henrikra/portfolio-flex/tree/master/assets/scripts
Do you guys usually unit test WP themes?

Writing tests is never a bad thing. However I don’t know many people that actually test themes. WP makes it pretty hard to easily write tests. Especially theme stuff.

If possible it’s better to extract functionality out of your theme and into separate plugins or mu-plugins. Then leave only the front-end/presentational stuff in the theme. The plugins are easier to test on their own.

1 Like