node-clinic/test-local/cli-flame-visualize-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

44 lines
1.3 KiB
JavaScript

'use strict'
const fs = require('fs')
const path = require('path')
const test = require('tap').test
const cli = require('../test/cli.js')
test('clinic flame --visualize-only - no issues', function (t) {
// collect data
cli({ relayStderr: false }, [
'clinic', 'flame', '--collect-only',
'--', 'node', '-e', 'setTimeout(() => {}, 300)'
], function (err, stdout, stderr, tempdir) {
t.error(err)
const dirname = stdout.match(/(\d+\.clinic-flame)/)[1]
const dirpath = path.resolve(tempdir, dirname)
// visualize data
cli({ relayStderr: false }, [
'clinic', 'flame', '--visualize-only', dirpath
], function (err, stdout) {
t.error(err)
const htmlFilename = stdout.match(/(\d+\.clinic-flame)/)[1]
// check that HTML file exists
fs.access(path.resolve(tempdir, htmlFilename), function (err) {
t.error(err)
t.end()
})
})
})
})
test('clinic flame --collect-only - missing data', function (t) {
cli({ relayStderr: false }, [
'clinic', 'flame', '--visualize-only', 'missing.flamegraph'
], function (err, stdout, stderr) {
t.strictSame(err, new Error('process exited with exit code 1'))
t.equal(stdout, '')
t.match(stderr, /Unknown argument "missing\.flamegraph"\. Pattern: {pid}\.clinic-{command}/)
t.end()
})
})