Test-Drive the BootStrap Code
The code weâll place in public/src/main.js will bootstrap the TasksComponent when the documentâs DOMContentLoaded event is fired. Following our tradition, weâll write a test for that before we implement the code.
As a first step, open the karma.conf.js file once more and add a reference to the ./public/src/main.js file, but add this as the last entry in the files section. We want the file main.js to be loaded after the component file has been loaded. Restart Karma after saving this file.
We need to intercept the addEventListener function and stub it out before it gets called in main.js. Since that file is loaded last, we have plenty of time to take care of it, provided we put the stub code in the right place. ...
Get Test-Driving JavaScript Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.