Code Monkey home page Code Monkey logo

just-make-sure's Introduction

justmakesure.js

justmakesure is an EXTREMELY minimal javascript testing tool.
I was working on a small-ish project and just wanted to make sure a few things were working as intended. I had no internet access to download a library so I wrote this quick and dirty tool.
It is meant to be as easy and as quick as possible to test really basic functionality for small projects.

Usage

Add justmakesure.js and justmakesure.css to an html page along with the file you want to test and a test file (or write your tests in your html), open up the html file in your favorite browser and see the results.
Tests that return true will be considered passing. For example:

var a = 3;
            
MAKE_SURE.after_each = function() { a = 3 };
            
// This will pass
makeSure("Multiplying 3 by 4 gives 12", function() {
	a *= 4;
	return a === 12;
});
            
// This will fail
makeSure("Adding 17 to 3 gives 21", function() {
	a += 17;
	return a === 21;
});
            
// This will throw an exception
makeSure("Calling plusOne on 3 gives 4", function() {
	a.plusOne();
	return a === 4;
});
            
// Testing objects
makeSure("An array of numbers is sorted correctly", function() {
	var actual   = [2, 1, 4, 3].sort(),
	expected = [1, 2, 3, 4];
	return JSON.stringify(actual) === JSON.stringify(expected);
});

Please feel free to use and imporove this tool! Email me with ideas or fork and pull.

just-make-sure's People

Contributors

assafgelber avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.