node-clinic/test/cli-bubbleprof-collect-only.test.js
Rafael Gonzaga 87e8a215dc
chore: add ci support node 16 (#292)
* chore: bump tap version

* chore: add v16 to test matrix

* chore: update coverage settings to latest tap version

* chore: use taprc

* chore: support v17

* chore: updade coverage settings
2021-10-28 09:41:21 -03:00

47 lines
1.4 KiB
JavaScript

'use strict'
const fs = require('fs')
const path = require('path')
const test = require('tap').test
const cli = require('./cli.js')
test('clinic bubbleprof --collect-only - no issues', function (t) {
cli({}, [
'clinic', 'bubbleprof', '--collect-only', '--debug',
'--', 'node', '-e', 'setTimeout(() => {}, 100)'
], function (err, stdout, stderr, tempdir) {
t.error(err)
t.ok(/Output file is \.clinic[/\\](\d+).clinic-bubbleprof/.test(stdout))
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-bubbleprof)/)[1]
fs.access(path.resolve(tempdir, dirname), function (err) {
t.error(err)
fs.access(path.resolve(tempdir, dirname + '.html'), function (err) {
t.equal(err.code, 'ENOENT')
t.end()
})
})
})
})
test('clinic bubbleprof --collect-only - bad status code', function (t) {
cli({ relayStderr: false }, [
'clinic', 'bubbleprof', '--collect-only',
'--', 'node', '-e', 'process.exit(1)'
], function (err, stdout, stderr, tempdir) {
t.error(err)
t.ok(/Output file is \.clinic[/\\](\d+).clinic-bubbleprof/.test(stdout))
const dirname = stdout.match(/(\.clinic[/\\]\d+.clinic-bubbleprof)/)[1]
fs.access(path.resolve(tempdir, dirname), function (err) {
t.error(err)
fs.access(path.resolve(tempdir, dirname + '.html'), function (err) {
t.equal(err.code, 'ENOENT')
t.end()
})
})
})
})