From 0a068db450782fd069fa5dc95f0764f8464f6846 Mon Sep 17 00:00:00 2001 From: telenord Date: Wed, 6 Nov 2019 17:32:13 +0300 Subject: [PATCH] test: test cover cases when trace is empty cover prepare_stack_trace in case when trace is empty PR-URL: https://github.com/nodejs/node/pull/30311 Reviewed-By: Gireesh Punathil --- test/fixtures/source-map/emptyStackError.js | 6 ++++++ test/parallel/test-source-map.js | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/fixtures/source-map/emptyStackError.js diff --git a/test/fixtures/source-map/emptyStackError.js b/test/fixtures/source-map/emptyStackError.js new file mode 100644 index 00000000000000..b02367a180dab7 --- /dev/null +++ b/test/fixtures/source-map/emptyStackError.js @@ -0,0 +1,6 @@ +"use strict"; + +Error.stackTraceLimit = 0; +throw new RangeError('emptyStackError'); + + diff --git a/test/parallel/test-source-map.js b/test/parallel/test-source-map.js index 13fa391aafefcc..ec2241f985281d 100644 --- a/test/parallel/test-source-map.js +++ b/test/parallel/test-source-map.js @@ -255,6 +255,18 @@ function nextdir() { } } +// trace.length === 0 . +{ + const output = spawnSync(process.execPath, [ + '--enable-source-maps', + require.resolve('../fixtures/source-map/emptyStackError.js') + ]); + + assert.ok( + output.stderr.toString().match('emptyStackError') + ); +} + function getSourceMapFromCache(fixtureFile, coverageDirectory) { const jsonFiles = fs.readdirSync(coverageDirectory); for (const jsonFile of jsonFiles) {