cypress-io / cypress-io/code-coverage

tilde in a string throws error

Open
#542 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
445
Forks
115
PR merge metrics
No merged PRs in 30d

Description

**Versions**
"cypress": "^9.1.0",
"@cypress/code-coverage": "^3.9.12",

**Describe the bug**
I have a line in my code :
```js
mask += '~`!@#$%^&*()_+-={}[]:";\'<>?,./|\\';
```
this is leading to an error : SyntaxError: Unexpected token x in JSON at position 2509710
from the command
```js
const coverage = JSON.parse(sentCoverage)
```
from `code-coverage/task.js`

when I dive into the sentCoverage it is a string generated by the command `JSON.stringify(appCoverageOnly)`, it looks like this in the problematic section:
```
}\n if (chars.indexOf('!') > -1) {\n mask += '\x7e`!@#$%^&*()_+-={}[]:\";\\'<>?,./|\\\\';\n }\n\n `

```

Basically my tilde is getting converted to \x7e and this cannot be parsed as JSON. Everything works perfectly if I just get rid of that one character

Please let me know if more details are warranted.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.