Skip to content

Commit

Permalink
don't include internal filenames in snapshots
Browse files Browse the repository at this point in the history
Some of these changed in node v10
  • Loading branch information
isaacs committed May 8, 2018
1 parent 5303417 commit f9d64f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tap-snapshots/test-spawn.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ not ok 1 - spawn something that does not exist ENOENT
at:
line: #
column: #
file: util.js
file: #INTERNAL#
code: ENOENT
command: something that does not exist
cwd: {CWD}
Expand Down
6 changes: 6 additions & 0 deletions test/clean-stacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Just a utility to clean up the snapshots for output tests

const yaml = require('js-yaml')
const internals = Object.keys(process.binding('natives'))

module.exports = out => out
// sort keys in yaml blocks
.replace(/\n( *)---\n((\1.*\n)*)\1\.\.\.\n/g, ($0, $1, $2) => {
Expand Down Expand Up @@ -44,6 +46,10 @@ module.exports = out => out
.replace(/\n( +)function: .*(\n\1 .*)*\n/g, '\n')
.replace(/\n( +)method: .*(\n\1 .*)*\n/g, '\n')
.replace(/\n( +)type: .*\n/g, '\n')
.replace(/\n( +)file: (.*)\n/g, ($0, $1, $2) =>
internals.indexOf($2.replace(/\.js$/, '')) === -1 ? $0
: '\n' + $1 + 'file: #INTERNAL#\n'
)

// timeout values are different when coverage is present
.replace(/\n( *)timeout: (30000|240000)(\n|$)/g, '\n$1timeout: {default}$3')
Expand Down

0 comments on commit f9d64f6

Please sign in to comment.