# Why I Test Private Functions In JavaScript

DevFeed: [Why I Test Private Functions In JavaScript](<https://devfeed.tech/articles/why-i-test-private-functions-in-javascript-29534.md>)

Original publisher: [Read original article](<https://philipwalton.com/articles/why-i-test-private-functions-in-javascript/>)

Published: 2013-07-17T15:47:00Z

Content type: opinion

Language: en

Sources: [Philip Walton](<https://devfeed.tech/sources/philip-walton.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Unit testing](<https://devfeed.tech/topics/unit-testing.md>), [Testing](<https://devfeed.tech/topics/testing.md>)

Tags: [behavior](<https://devfeed.tech/tags/behavior.md>), [closure](<https://devfeed.tech/tags/closure.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [testing](<https://devfeed.tech/tags/testing.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>)

## AI overview

The author explains why they test some JavaScript code inside closures, responding to criticism that testing private functions is unnecessary or indicates poor design. They clarify that they are not advocating testing every private function or claiming that developers who disagree are wrong.

## Source excerpt

Last week I published an article on this blog entitled How to Unit Test Private Functions in JavaScript. The article was well received and even mentioned in a few popular newsletters (most notably JavaScript Weekly). Still, a decent amount of the feedback I received in the comments and on Twitter strongly disagreed with my approach. The most common criticism was: unit testing private functions is unnecessary and a mark of bad design.