1.0.31 • Published 3 years ago

@jdeighan/ava-tester v1.0.31

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Project: AvaTester

The point of AvaTester is to simplify unit testing:

  1. Using the ava unit test system
  2. No need to name individual tests, they're identified by line number
  3. Duplicate line numbers won't cause an error
  4. Strings are "normalized" before comparison:
    • leading and trailing whitespace is removed
    • runs of whitespace collapse to a single space char
    • empty lines are removed
    • you can override the normalize() method
  5. You can define a transformValue() method

Examples (coffeescript syntax):

import {AvaTester} from 'ava-tester'

tester = new AvaTester()

# --- tester.equal tests deep equality

tester.equal     7, 'abc', 'abc'
tester.equal     8, ['a','b'], [  'a',   'b',  ]
tester.truthy    9, 42
tester.falsy    10, null
tester.notequal 11, 'abc', 'def'
tester.fails    12, () -> throw new Error("bad")
tester.different 13, ['a'], ['a']

lItems = ['a', 'b']
tester.same 16, lItems, lItems

Test creating custom tester

class CapTester extends AvaTester

	transformValue: (input) ->
		return input.toUpperCase()

capTester = new CapTester()

capTester.equal 26, 'abc', 'ABC'
capTester.equal 27, 'ABC', 'ABC'
capTester.notequal 28, 'abc', 'abc'

Test string normalization

tester.equal 31, """
		line 1

		line     2

		line 3
		""", """
		line 1
		line 2
		line 3
		"""

Available Test Methods:

truthy
falsy
equal
notequal
same
different
fails
1.0.22

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago