AMD (short for Asynchronous Module Definition) is a JavaScript API specification for structuring modular code. The web abounds with blog posts illustrating its use in front-end application development (and there’s plenty of healthy debate around its necessity, too). The topic of unit testing (despite being integral to the process of software development) does not receive much attention in these discussions.
As it happens, AMD has an impact on how one authors tests. More than just dictating some additional function calls, AMD (and the RequireJS library in particular) can actually enhance unit test suites.
Finally, if you’re convinced AMD is right for your project, then the truth is: your hands may be tied. The structure of an application dictates the structure of its unit tests. This means your test environment is going to have to account for that sweet, sweet asynchronicity of your module definitions.
Your new post is loading...