1 | 'use strict'
|
2 |
|
3 | const test = require('tap').test
|
4 | const path = require('path')
|
5 | const { spawn } = require('child_process')
|
6 | const endpoint = require('endpoint')
|
7 |
|
8 | test('cmd - collect - NODE_PATH works', function (t) {
|
9 | t.plan(2)
|
10 |
|
11 | const child = spawn(
|
12 | process.execPath, [
|
13 | require.resolve('./cmd-collect-node-path-env.script.js')
|
14 | ], {
|
15 | env: Object.assign({}, process.env, { NODE_PATH: __dirname })
|
16 | }
|
17 | )
|
18 |
|
19 | child.on('exit', function (code) {
|
20 | t.strictEqual(code, 0)
|
21 | })
|
22 |
|
23 | child.stdout.pipe(endpoint(function (err, output) {
|
24 | if (err) return t.ifError(err)
|
25 |
|
26 | t.strictEqual(output.toString().trim(), `${path.join(__dirname, '../injects')}${path.delimiter}${__dirname}
|
27 | Profile data collected seems to be empty, report may not be generated`)
|
28 | }))
|
29 | })
|