fix #1115: add a special-cased error message

This commit is contained in:
Evan Wallace
2021-04-07 03:01:22 -07:00
parent 5dc64cb97b
commit 99b260670b
4 changed files with 136 additions and 1 deletions

View File

@@ -80,6 +80,44 @@
}),
)
// Test coverage for a special JSX error message
tests.push(
test(['example.jsx', '--outfile=node.js'], {
'example.jsx': `let button = <Button content="some so-called \\"button text\\"" />`,
}, {
expectedStderr: ` > example.jsx:1:58: error: Unexpected backslash in JSX element
1 │ let button = <Button content="some so-called \\"button text\\"" />
╵ ^
example.jsx:1:45: note: JSX attributes use XML-style escapes instead of JavaScript-style escapes
1 │ let button = <Button content="some so-called \\"button text\\"" />
│ ~~
╵ &quot;
example.jsx:1:29: note: Consider using a JavaScript string inside {...} instead of a JSX attribute
1 │ let button = <Button content="some so-called \\"button text\\"" />
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
╵ {"some so-called \\"button text\\""}
`,
}),
test(['example.jsx', '--outfile=node.js'], {
'example.jsx': `let button = <Button content='some so-called \\'button text\\'' />`,
}, {
expectedStderr: ` > example.jsx:1:58: error: Unexpected backslash in JSX element
1 │ let button = <Button content='some so-called \\'button text\\'' />
╵ ^
example.jsx:1:45: note: JSX attributes use XML-style escapes instead of JavaScript-style escapes
1 │ let button = <Button content='some so-called \\'button text\\'' />
│ ~~
╵ &apos;
example.jsx:1:29: note: Consider using a JavaScript string inside {...} instead of a JSX attribute
1 │ let button = <Button content='some so-called \\'button text\\'' />
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
╵ {'some so-called \\'button text\\''}
`,
}),
)
// Tests for symlinks
//
// Note: These are disabled on Windows because they fail when run with GitHub