MCPcopy
hub / github.com/brianc/node-postgres / expect

Function expect

packages/pg/test/test-helper.js:27–61  ·  view source on GitHub ↗
(callback, timeout)

Source from the content-addressed store, hash-verified

25 process.exit(255)
26})
27const expect = function (callback, timeout) {
28 const executed = false
29 timeout = timeout || parseInt(process.env.TEST_TIMEOUT) || 5000
30 const id = setTimeout(function () {
31 assert.ok(
32 executed,
33 'Expected execution of function to be fired within ' +
34 timeout +
35 ' milliseconds ' +
36 ' (hint: export TEST_TIMEOUT=<timeout in milliseconds>' +
37 ' to change timeout globally)' +
38 callback.toString()
39 )
40 }, timeout)
41
42 if (callback.length < 3) {
43 return function (err, queryResult) {
44 clearTimeout(id)
45 if (err) {
46 assert.ok(err instanceof Error, 'Expected errors to be instances of Error: ' + sys.inspect(err))
47 }
48 callback.apply(this, arguments)
49 }
50 } else if (callback.length == 3) {
51 return function (err, arg1, arg2) {
52 clearTimeout(id)
53 if (err) {
54 assert.ok(err instanceof Error, 'Expected errors to be instances of Error: ' + sys.inspect(err))
55 }
56 callback.apply(this, arguments)
57 }
58 } else {
59 throw new Error('Unsupported arrity ' + callback.length)
60 }
61}
62// print out the filename
63process.stdout.write(require('path').basename(process.argv[1]))
64if (isNativeMode) process.stdout.write(' (native)')

Callers 15

clientConfig.tsFile · 0.85
parse.tsFile · 0.85
lifecycle-hooks.jsFile · 0.85
index.jsFile · 0.85
submittable.jsFile · 0.85
logging.jsFile · 0.85
error-handling.jsFile · 0.85
sizing.jsFile · 0.85
ending.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected