From e0eb38cfdc956a30f7822544fb38a210c745e907 Mon Sep 17 00:00:00 2001 From: Edy Silva Date: Wed, 2 Oct 2024 00:45:28 -0300 Subject: [PATCH] test: test case when --enable-source-maps is provided --- test/parallel/test-runner-coverage.js | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/parallel/test-runner-coverage.js b/test/parallel/test-runner-coverage.js index 77e0afadbdff95..681ea09ffd0fba 100644 --- a/test/parallel/test-runner-coverage.js +++ b/test/parallel/test-runner-coverage.js @@ -321,6 +321,43 @@ test('coverage with source maps', skipIfNoInspector, () => { assert.strictEqual(result.status, 1); }); + +test('coverage with --enable-source-maps option', skipIfNoInspector, () => { + const fixture = fixtures.path('test-runner', 'coverage', 'stdin.test.js'); + const args = [ + '--test', '--experimental-test-coverage', '--enable-source-maps', '--test-reporter', 'tap', + fixture, + ]; + + const report = [ + '# start of coverage report', + '# ------------------------------------------------------------------', + '# file | line % | branch % | funcs % | uncovered lines', + '# ------------------------------------------------------------------', + '# test | | | | ', + '# fixtures | | | | ', + '# test-runner | | | | ', + '# coverage | | | | ', + '# stdin.test.ts | 57.14 | 100.00 | 100.00 | 4-6', + '# ------------------------------------------------------------------', + '# all files | 57.14 | 100.00 | 100.00 | ', + '# ------------------------------------------------------------------', + '# end of coverage report', + ].join('\n'); + + if (common.isWindows) { + report = report.replaceAll('/', '\\'); + } + + const result = spawnSync(process.execPath, args); + const stdOut = result.stdout.toString(); + + assert.strictEqual(result.stderr.toString(), ''); + assert(!stdOut.includes('TypeError')); + assert(stdOut.includes(report)); + assert.strictEqual(result.status, 0); +}); + test('coverage with source maps missing sources', skipIfNoInspector, () => { const file = fixtures.path('test-runner', 'source-map-missing-sources', 'index.js'); const missing = fixtures.path('test-runner', 'source-map-missing-sources', 'nonexistent.js');