title: Evaluation problems with Jasmine JavaScript testing framework
body: <p>I'm experiencing problems with the Jasmine (ver. 2.4) JavaScript testing framework.</p>
  
  <p>I'm creating a course on udemy.com, but the online checker won't accept the last part of my code, where I'm using the "expect(variable).toBe(true);" function of Jasmine.</p>
  
  <pre><code>describe('A div with class', function() {
    var parent = document.getElementsByClassName('media')[0];
  
    it('"media" should exist.', function() {
      expect(parent).toBeDefined();
    });
  
    var child = document.getElementsByClassName('media-body')[0];
  
    it('"media-body" should exist.', function() {
      expect(child).toBeDefined();
    });
  
  });
  
  describe('A div with class "media"', function() {
    var parent = document.getElementsByClassName('media')[0];
    var child = document.getElementsByClassName('media-body')[0];
  
    var answer;
  
    if (parent.firstChild == child) {
      answer = true;
    } else {
      answer = false;
    }
  
    it('should have a div with class "media-body" as its child.', function() {
      expect(answer).toBe(true);
    });
  
  });
  </code></pre>
  
  <p>My test output from the udemy.com page is:</p>
  
  <p>"A div with class "media" should have a div with class "media-body" as its child.</p>
  
  <p>Expected false to be true"</p>
  
  <p>My updated code which now works very well:</p>
  
  <pre><code>describe('A div with the class', function() {
  
  var class1 = 'media';
  var failClass1 = '"' + class1 + '"' + ' should exist.'
  
  var class2 = 'media-body';
  var failClass2 = '"' + class2 + '"' + ' should exist.'
  
  var element1 = null;
  var element2 = null;
  
  var relationship1_2 = null;
  var failRelationship = '"' + class2 + '"' + ' should be nested in a div with the class "' + class1 + '".'
  
  beforeEach(function() {
    element1 = document.getElementsByClassName(class1)[0];
    element2 = document.getElementsByClassName(class2)[0];
    relationship1_2 = element1.contains(element2);
  })
  
  it(failClass1, function() {
    expect(element1).toBeDefined();
  });
  
  it(failClass2, function() {
    expect(element2).toBeDefined();
  });
  
  it(failRelationship, function() {
    expect(relationship1_2).toBe(true);
  });
  </code></pre>
  
  <p>});</p>