node-clinic/test/cli-flame-non-node.test.js
2020-04-23 13:18:13 +02:00

29 lines
1.0 KiB
JavaScript

'use strict'
const test = require('tap').test
const cli = require('./cli.js')
test('clinic flame - should error early if non-node script', function (t) {
cli({}, ['clinic', 'flame', '--', 'sh', 'wrapper.sh'], function (err, stdout) {
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
t.ok(/Clinic.js Flame[^\w ]/.test(stdout.split('\n')[1]))
t.end()
})
})
test('clinic flame --collect-only - should error early if non-node script', function (t) {
cli({}, ['clinic', 'flame', '--collect-only', '--', 'sh', 'wrapper.sh'], function (err, stdout) {
t.strictDeepEqual(err, new Error('process exited with exit code 1'))
t.ok(/Clinic.js Flame[^\w ]/.test(stdout.split('\n')[1]))
t.end()
})
})
test('clinic flame - should accept full path to node.js', function (t) {
cli({}, ['clinic', 'flame', '--no-open', '--', process.execPath, '-e', 'setTimeout(() => {}, 10)'], function (err, stdout) {
t.ifError(err)
t.ok(/Generated HTML file is (.*?)\.clinic[/\\](\d+).clinic-flame/.test(stdout))
t.end()
})
})