Skip to content

Commit 7363eec

Browse files
committed
Tests for webpack:// url parsing
1 parent 2a3e704 commit 7363eec

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

test/vendor/fixtures/captured-errors.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ CapturedExceptions.CHROME_36 = {
173173
" at I.e.fn.(anonymous function) [as index] (http://localhost:8080/file.js:10:3651)"
174174
};
175175

176+
// can be generated when Webpack is built with { devtool: eval }
177+
CapturedExceptions.CHROME_XX_WEBPACK = {
178+
message: "Cannot read property 'error' of undefined",
179+
name: "TypeError",
180+
stack: "TypeError: Cannot read property 'error' of undefined\n" +
181+
" at TESTTESTTEST.eval(webpack:///./src/components/test/test.jsx?:295:108)\n" +
182+
" at TESTTESTTEST.render(webpack:///./src/components/test/test.jsx?:272:32)\n" +
183+
" at TESTTESTTEST.tryRender(webpack:///./~/react-transform-catch-errors/lib/index.js?:34:31)\n" +
184+
" at TESTTESTTEST.proxiedMethod(webpack:///./~/react-proxy/modules/createPrototypeProxy.js?:44:30)"
185+
};
186+
176187
CapturedExceptions.FIREFOX_3 = {
177188
fileName: "http://127.0.0.1:8000/js/stacktrace.js",
178189
lineNumber: 44,

test/vendor/tracekit-parser.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ describe('TraceKit', function () {
123123
assert.deepEqual(stackFrames.stack[2], { url: 'http://localhost:8080/file.js', func: 'I.e.fn.(anonymous function) [as index]', args: [], line: 10, column: 3651 });
124124
});
125125

126+
it('should parse Chrome error with webpack URLs', function () {
127+
var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.CHROME_XX_WEBPACK);
128+
assert.ok(stackFrames);
129+
assert.deepEqual(stackFrames.stack.length, 4);
130+
assert.deepEqual(stackFrames.stack[0], { url: 'webpack:///./src/components/test/test.jsx?', func: 'TESTTESTTEST.eval', args: [], line: 295, column: 108 });
131+
assert.deepEqual(stackFrames.stack[1], { url: 'webpack:///./src/components/test/test.jsx?', func: 'TESTTESTTEST.render', args: [], line: 272, column: 32 });
132+
assert.deepEqual(stackFrames.stack[2], { url: 'webpack:///./~/react-transform-catch-errors/lib/index.js?', func: 'TESTTESTTEST.tryRender', args: [], line: 34, column: 31 });
133+
assert.deepEqual(stackFrames.stack[3], { url: 'webpack:///./~/react-proxy/modules/createPrototypeProxy.js?', func: 'TESTTESTTEST.proxiedMethod', args: [], line: 44, column: 30 });
134+
});
135+
126136
it('should parse Chrome error with blob URLs', function () {
127137
var stackFrames = TraceKit.computeStackTrace(CapturedExceptions.CHROME_48_BLOB);
128138
assert.ok(stackFrames);

0 commit comments

Comments
 (0)