Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
ntf is a network testing framework written in Node.js.
Install ntf
npm install ntf
npm install ntf -g
Create a file named ntfjs.org.js
var ntf = require('ntf')
, test = ntf.http('http://ntfjs.org')
exports.homepage = test.get('/', function(test) {
test.statusCode(200)
test.body('ntf')
test.done()
})
Run the tests
ntf ntfjs.org.js
## Documentation
Test DNS records.
var ntf = require('ntf')
, dns = ntf.dns()
### dns.a(name, callback)
Resolve an IPv4 address record.
Arguments
Example
exports.a = dns.a('a.dns.ntfjs.org', function(test) {
test.address('127.0.0.1')
test.done()
})
### dns.aaaa(name, callback)
Resolve an IPv6 address record.
Arguments
Example
exports.aaaa = dns.aaaa('aaaa.dns.ntfjs.org', function(test) {
test.address('::1')
test.done()
})
### dns.cname(name, callback)
Resolve a canonical name record.
Arguments
Example
exports.cname = dns.cname('cname.dns.ntfjs.org', function(test) {
test.name('a.dns.ntfjs.org')
test.done()
})
### dns.mx(name, callback)
Resolve a mail exchange record.
Arguments
Example
exports.mx = dns.mx('mx.dns.ntfjs.org', function(test) {
test.name('mx1.dns.ntfjs.org')
test.done()
})
### dns.ns(name, callback)
Resolve a name server record.
Arguments
Example
exports.ns = dns.ns('ns.dns.ntfjs.org', function(test) {
test.name('ns1.dns.ntfjs.org')
test.done()
})
### dns.ptr(ip, callback)
Resolve a pointer record.
Arguments
Example
exports.ptr = dns.ptr('50.116.49.237', function(test) {
test.name('hub.sewell.org')
test.done()
})
### dns.srv(name, callback)
Resolve a service location record.
Arguments
Example
exports.srv = dns.srv('_ntfjs', function(test) {
test.name('srv1.dns.ntfjs.org')
test.done()
})
### dns.txt(name, callback)
Resolve a text record.
Arguments
Example
exports.txt = dns.txt('_ntfjs', function(test) {
test.done()
})
### test.address(ip)
Assert answer contains IP address.
Arguments
Example
exports.a = dns.a('a.dns.ntfjs.org', function(test) {
test.address('127.0.0.1')
test.done()
})
### test.name(name)
Assert answer contains name.
Arguments
Example
exports.cname = dns.cname('cname.dns.ntfjs.org', function(test) {
test.name('a.dns.ntfjs.org')
test.done()
})
## HTTP
Test HTTP requests.
var ntf = require('ntf')
, http = ntf.http('http://http.ntfjs.org')
### http.request(options, callback)
Execute an HTTP request.
__Arguments__Example
exports.request = http.request('/', function(test) {
test.statusCode(200)
test.done()
})
### http.del(options, callback)
Execute an HTTP delete request.
Arguments
Example
exports.del = http.del('/delete', function(test) {
test.statusCode(200)
test.done()
})
### http.get(options, callback)
Execute an HTTP get request.
Arguments
Example
exports.get = http.get('/get', function(test) {
test.statusCode(200)
test.done()
})
### http.head(options, callback)
Execute an HTTP head request.
Arguments
Example
exports.head = http.head('/head', function(test) {
test.statusCode(200)
test.done()
})
### http.options(options, callback)
Execute an HTTP options request.
Arguments
Example
exports.options = http.options('/options', function(test) {
test.statusCode(200)
test.done()
})
### http.patch(options, callback)
Execute an HTTP patch request.
Arguments
Example
exports.patch = http.patch('/patch', function(test) {
test.statusCode(200)
test.done()
})
### http.post(options, callback)
Execute an HTTP post request.
Arguments
Example
exports.post = http.post({ url: '/post', body: { 'q': 'test' } }), function(test) {
test.statusCode(201)
test.done()
})
### http.put(options, callback)
Execute an HTTP put request.
Arguments
Example
exports.put = http.put({ url: '/put', body: 'put' }), function(test) {
test.statusCode(201)
test.done()
})
### test.body([match[, compare...]])
Tests match
against body and returns result.
Arguments
Example
exports.get = http.get('/', function(test) {
test.body(/<title>(.*)<\/title>/, 'ntf')
test.done()
})
### test.cookie([name[, match]])
Tests cookie existence/value and returns match.
Arguments
Example
exports.get = http.get('/', function(test) {
test.cookie('sid', /^[a-f0-9]+$/)
test.done()
})
### test.header([name[, match]])
Tests header existence/value and returns match.
Arguments
Example
exports.get = http.get('/', function(test) {
test.header('Content-Type', 'text/html')
test.done()
})
### test.json([match])
Tests body against match and returns parsed JSON.
Arguments
Example
exports.get = http.get('/', function(test) {
test.json({ one: 'two' })
test.done()
})
### test.jsonPath([path[, compare...]])
Tests json path against compares and returns result.
Arguments
Example
exports.get = http.get('/', function(test) {
test.jsonPath('$.book.title', 'Second Foundation', "The Wise Man's Fear")
test.done()
})
### test.statusCode(code)
Tests response status code.
Arguments
Example
exports.get = http.get('/', function(test) {
test.statusCode(200)
test.done()
})
## Socket
Test socket connections.
var ntf = require('ntf')
, socket = ntf.socket('ntfjs.org')
### socket.tcp(port, callback)
Open TCP connection to host and port.
Arguments
Example
exports.tcp = socket.tcp(25, function(test) {
test.connect()
test.done()
})
### test.connect(code)
Tests connection was opened.
Example
exports.tcp = socket.tcp(25, function(test) {
test.connect()
test.done()
})
This work is licensed under the MIT License (see the LICENSE file).
FAQs
Network Testing Framework
The npm package ntf receives a total of 3 weekly downloads. As such, ntf popularity was classified as not popular.
We found that ntf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.