Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: add coverage tests for sourceMapFromDataUrl method #30319

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/fixtures/source-map/inline-base64-json-error.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/fixtures/source-map/inline-base64-type-error.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions test/parallel/test-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,38 @@ function nextdir() {
);
}

// base64 encoding error does not crash application.
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a comment above both of these blocks that describes the purpose of the test, e.g.,

"base64 encoding error does not crash application".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty of adding two comments. LGTY?

const coverageDirectory = nextdir();
const output = spawnSync(process.execPath, [
require.resolve('../fixtures/source-map/inline-base64-type-error.js')
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
assert.strictEqual(output.status, 0);
assert.strictEqual(output.stderr.toString(), '');
const sourceMap = getSourceMapFromCache(
'inline-base64-type-error.js',
coverageDirectory
);

assert.strictEqual(sourceMap.data, null);
}

// JSON error does not crash application.
{
const coverageDirectory = nextdir();
const output = spawnSync(process.execPath, [
require.resolve('../fixtures/source-map/inline-base64-json-error.js')
], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } });
assert.strictEqual(output.status, 0);
assert.strictEqual(output.stderr.toString(), '');
const sourceMap = getSourceMapFromCache(
'inline-base64-json-error.js',
coverageDirectory
);

assert.strictEqual(sourceMap.data, null);
}

// Does not apply source-map to stack trace if --experimental-modules
// is not set.
{
Expand Down