Open Mic

images/js/q-risk.png

Yes. Good point. When we embed HTML directly into our unit tests, we absolutely run the risk of them getting out of sync with the actual HTML files. If you’re not careful, you could end up in the situation where your unit tests pass and your production code fails—precisely because they differ!

That’s why many frameworks allow you to load fixtures externally from files like this:

 describe(​"When selecting elements for employee - external fixture"​, ​function​(){
 
 var​ model;
 
  beforeEach(​function​() {
  loadFixtures(​'ListboxFixture.html'​);
  model = ​new​ EmployeeModel();
  });
 
  it(​"should be able to get Onsite"​, ​function ...

Get The Way of the Web Tester 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.