Skip to content

Commit

Permalink
Merge pull request #704 from ktutnik/fix-array-flat-issue
Browse files Browse the repository at this point in the history
fix: Fix unappropriate stack trace issue on Node.js prior than v14
  • Loading branch information
niftylettuce committed Jan 25, 2021
2 parents abd2f45 + 0a06ef1 commit 967aff1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,8 @@ language: node_js

node_js:
- lts/*
- 12
- 10

before_install:
- npm i
Expand Down
6 changes: 5 additions & 1 deletion lib/test.js
Expand Up @@ -80,7 +80,11 @@ function wrapAssertFn(assertFn) {
var err = assertFn(res);
if (err && err.stack) {
badStack = err.stack.replace(err.message, '').split('\n').slice(1);
err.stack = [err.toString(), savedStack, '----', badStack].flat().join('\n');
err.stack = [err.toString()]
.concat(savedStack)
.concat('----')
.concat(badStack)
.join('\n');
}
return err;
};
Expand Down
2 changes: 1 addition & 1 deletion test/supertest.js
Expand Up @@ -531,7 +531,7 @@ describe('request(app)', function () {
.get('/')
.expect({ stringValue: 'foo', numberValue: 3, nestedObject: { innerString: 5 } })
.end(function (err, res) {
err.message.should.equal('expected {\n stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: 5 }\n} response body, got {\n stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: \'5\' }\n}'); // eslint-disable-line max-len
err.message.replace(/[^a-zA-Z]/g, '').should.equal('expected {\n stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: 5 }\n} response body, got {\n stringValue: \'foo\',\n numberValue: 3,\n nestedObject: { innerString: \'5\' }\n}'.replace(/[^a-zA-Z]/g, '')); // eslint-disable-line max-len
shouldIncludeStackWithThisFile(err);

request(app)
Expand Down

0 comments on commit 967aff1

Please sign in to comment.