Skip to content

Astronautilus14/Testing-JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Testing-JS

A testing library, designed for front-end javascript.

Setup

Add the following tag to the header of your HTML

<script type="text/javascript" src="http://nautdevroome.nl/testing.js"></script>

When you have implemented you JS function like this

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

You can write a test case for it like this, as long as it ends on Test

function plusTest() {
   assertEquals(plus(1, 3), 4);
}

Now you will see the result of your test in the console

plusTest✅ Runtime≈0.400000ms

Functions

Before each

This will called before each test case

function beforeEach() {
  array = [];
  console.log('Ready!');
}

After each

This will called after each test case

function afterEach() {
  console.log('Im done!');
}

Assert equals

Takes 2 arguments and compares them

function plusTest() {
   assertEquals(4, 4);
}

When comparing 2 string and they are not, the fail message will indicate the first character that differs.

When comparing 2 arguments which are aqual, but have a different type, the fail message will show the types of the 2 arguments.

Assert not equals

Takes 2 arguments and compares them

function plusTest() {
   assertNotEquals(3, 4);
}

Assert true

Takes 1 arguments checks if it is true or 1

function plusTest() {
   assertTrue(1 == 1);
}

Assert false

Takes 1 arguments checks if it is false or 0

function plusTest() {
   assertFalse(1 == 2);
}

About

A testing framework for javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published