Skip to content

My implementation of some of the JavaScript Array methods with TDD :bowtie:

License

Notifications You must be signed in to change notification settings

eralpkor/test-driven-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test-driven-javascript

Watch and Code project: Write your own implementation of JavaScript array methods.

All of the methods are in test directory

How does tiny test works: This is an in-browser JavaScript library I've been using for years. It's so small and simple that it never occured to me to open source it until I saw all the overly complicated alternatives that are out there.

If you're looking for a JavaScript library full of features or install guides that say things like grunt, npm or bower, you've come to the wrong place. Sorry, this probably isn't for you. Move along now.

If you're looking for a quick way to unit-test a JavaScript function/object in a web-page and don't want to get bogged down in frameworks, you've come to the right place. Take a seat... no scratch that, you'll have everything you need in a few seconds so you may as well remain standing.

Download tinytest.js Example 10 second tutorial Download tinytest.js and put it somewhere in your web directory.

Let's say you have a function in adder.js:

function add(a, b) { return a + b; }

Create a test page called adder-test.html (you can name it anything). This includes your code under test, tinytest.js and defines your tests:

<script src="adder.js"></script>
<script>
 tests({

   'adds numbers': function() {
     eq(6, add(2, 4));
     eq(6.4, add(2.4, 4));
   },

   'subtracts numbers': function() {
     eq(-2, add(2, -4)); 
   },

 });
</script>

Open the page in your browser. Green is good. Red is bad. If it's red, look in the JavaScript console for messages.

About

My implementation of some of the JavaScript Array methods with TDD :bowtie:

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published