1.0.17 • Published 4 years ago

juzt v1.0.17

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

juzt

very simple js unit testing

Installation

$ npm install juzt

Usage

write descriptive tests that evaluate to true

/*
juzt tests take only two arguments:
a description string and a boolean expression
*/

const juzt = require('juzt')

// these tests will pass:

let a = 1
let b = 2
juzt.test('sum of a and b is 3', a + b === 3)
juzt.test('this test passes', true)
juzt.test('', true)
juzt.test('boolean expression', !!a)
juzt.test('boolean expression', !!'test')

let e = null
try { throwanerror() } catch (err) { e = err }
// juzt tests return true on pass and false on fail
if ( juzt.test('e should be an error', e instanceof Error) ) {
	juzt.test('with the correct type and message', e.name === 'ReferenceError' && e.message === 'throwanerror is not defined')
}

// these tests will fail:

b = 1
juzt.test('is the sum of a and b 3?', a + b === 3)
juzt.test('evaluates to false', false)
juzt.test('evaluates to false', !b)
juzt.test('evaluates to false', !'test')

let ee = null
try { a + b } catch (err) { ee = err }
juzt.test('is this an error?', ee instanceof Error)

// these will throw an error:

juzt.test('second argument must be boolean', a)
juzt.test('second argument must be boolean', 1)
juzt.test('second argument must be boolean', 0)
juzt.test(3, true)
juzt.test(true)
juzt.test()

// end testing

juzt.over()

run

node yourtest.js
Licensed under MIT
1.0.17

4 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago