Skip to content

Commit

Permalink
Mock out react error mapping responses
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jul 6, 2016
1 parent efdb416 commit e40b351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/sentry/lang/javascript/errormapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
logger = logging.getLogger(__name__)


REACT_MAPPING_URL = ('https://raw.githubusercontent.com/facebook/'
'react/master/scripts/error-codes/codes.json')


error_processors = {}


Expand Down Expand Up @@ -55,8 +59,7 @@ def decorator(f):

@minified_error(
vendor='react',
mapping_url=('https://raw.githubusercontent.com/facebook/'
'react/master/scripts/error-codes/codes.json'),
mapping_url=REACT_MAPPING_URL,
regex=r'Minified React error #(\d+); visit https?://[^?]+\?(\S+)'
)
def process_react_exception(exc, match, mapping):
Expand Down
13 changes: 12 additions & 1 deletion tests/sentry/lang/javascript/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
SourceProcessor, trim_line, UrlResult
)
from sentry.lang.javascript.sourcemaps import SourceMap, SourceMapIndex
from sentry.lang.javascript.errormapping import rewrite_exception
from sentry.lang.javascript.errormapping import (
rewrite_exception, REACT_MAPPING_URL
)
from sentry.models import Release
from sentry.testutils import TestCase

Expand Down Expand Up @@ -291,7 +293,16 @@ def test_get_culprit_is_patched(self):

class ErrorMappingTest(TestCase):

@responses.activate
def test_react_error_mapping_resolving(self):
responses.add(responses.GET, REACT_MAPPING_URL, body=r'''
{
"108": "%s.getChildContext(): key \"%s\" is not defined in childContextTypes.",
"109": "%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.",
"110": "Stateless function components cannot have refs."
}
''', content_type='application/json')

data = {
'platform': 'javascript',
'sentry.interfaces.Exception': {
Expand Down

0 comments on commit e40b351

Please sign in to comment.