Testing webtask.io programming models

Boris Verhaaff
Oct 26, 2017 · 3 min read

Testing the Simple function model

cb(error, result)
$ ./node_modules/.bin/tape simple-function.test.js 
TAP version 13
# Simple function test cases
ok 1 Assert expected: null matches actual: null
ok 2 Assert expected: {"i_am":"done "} matches actual: {"i_am":"done "}
1..2
# tests 2
# pass 2
# ok

Testing the Function with context model

$ ./node_modules/.bin/tape function-with-context.test.js 
TAP version 13
# Function with context test cases
ok 1 Assert expected: null matches actual: null
ok 2 Assert expected: {"hello_you":"Boris"} matches actual: {"hello_you":"Boris"}
ok 3 Assert expected: null matches actual: null
ok 4 Assert expected: {"hello_you":"Anonymous"} matches actual: {"hello_you":"Anonymous"}
1..4
# tests 4
# pass 4
# ok

Testing the Full HTTP control model

$ ./node_modules/.bin/tape full-http-control.test.js 
TAP version 13
# Full http control test cases
ok 1 Assert expected: 200 matches actual: 200
ok 2 Assert expected: {"Content-Type":"text/html "} matches actual: {"Content-Type":"text/html "}
ok 3 Assert expected: <h1>Hello, world!</h1> matches actual: <h1>Hello, world!</h1>
1..3
# tests 3
# pass 3
# ok

Summary

Code

Disclaimer

Connect

Boris Verhaaff

Written by

Software engineer, specialized in #PHP and #Javascript but not limited. Love for a wide range of technologies and open source software.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade