Skip to content
Mocking and stubbing in JavaScript.
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
javascripts
stylesheets
README
index.html

README

Moksi
-----

Moksi is a stubbing and mocking library for JavaScript.

  var Person {
    name: function() {
      return 'Alice';
    },
    age: function() {
      return 28;
    }
  }
  
  // Stub the person's name.
  Moksi.stub(Person, 'name', function(){
    return 'Bob';
  });
  Person.name() == 'Bob';
  
  // Expect age to be called
  Moksi.expects(Person, 'age');
  Person.age();
  Moksi.assertExpectations(this);
  
  // Revert all stubs and expectations
  Moksi.revert(); 
  Person.name() == 'Alice';
Something went wrong with that request. Please try again.