Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.css">
  
<script src="https://code.jquery.com/jquery-git.js"></script>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.js"></script>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/boot.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
 Testing jasmine
</body>
</html>
 
(function(){
  "use strict"
  describe("outer Describe", function(){
    var testArray;
    beforeEach(function(){
      testArray = [];
    });
    describe("First Describe", function(){
      beforeEach(function(){
        testArray.push({name: "foo"});
      });
      
      it("has an item", function(){
        expect(testArray.length).toBe(1);
      });
    });
    
    describe("Second describe", function(){
      var arrIsEmptyInBeforeAll;
      var arrIsEmptyInBeforeEach;
      beforeAll(function(){
        arrIsEmptyInBeforeAll = testArray.length === 0;
        console.log("testArray should be empty:");
        console.log(testArray);
      });
      
      beforeEach(function(){
        arrIsEmptyInBeforeEach = testArray.length === 0;
      });
      
      it("the arr was empty in before all", function(){
        expect(arrIsEmpty).toBeTruthy();
      });
      
      it("the arr was empty in beforeEach", function(){
        expect(arrIsEmptyInBeforeEach).toBeTruthy();
      })
    })
  });
})();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers