Izmjenjena struktura, dodan backand

This commit is contained in:
GotPPay
2017-10-16 11:19:46 +02:00
parent 1ec88afacb
commit 048e32c4aa
37153 changed files with 2975854 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
var _this = this;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { extractSourceMapUrl } from '../utils/getSourceMap';
test('extracts last source map directive', _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return extractSourceMapUrl('test.js', '//# sourceMappingURL=test.js.map\nconsole.log(\'a\')\n//# sourceMappingURL=bundle.js.map');
case 2:
res = _context.sent;
expect(res).toBe('bundle.js.map');
case 4:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
})));
test('errors when no source map', _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
var testFileName;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
expect.assertions(1);
testFileName = 'test.js';
_context2.prev = 2;
_context2.next = 5;
return extractSourceMapUrl(testFileName, 'console.log(\'hi\')\n\nconsole.log(\'bye\')');
case 5:
_context2.next = 10;
break;
case 7:
_context2.prev = 7;
_context2.t0 = _context2['catch'](2);
expect(_context2.t0).toBe('Cannot find a source map directive for ' + testFileName + '.');
case 10:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this, [[2, 7]]);
})));

View File

@@ -0,0 +1,110 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
var _this = this;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { getSourceMap } from '../utils/getSourceMap';
import fs from 'fs';
import { resolve } from 'path';
test('finds an external source map', _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var file, sm;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
file = fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs')).toString('utf8');
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs.map')).toString('utf8'));
_context.next = 4;
return getSourceMap('/', file);
case 4:
sm = _context.sent;
expect(sm.getOriginalPosition(26122, 21)).toEqual({
line: 7,
column: 0,
source: 'webpack:///packages/react-scripts/template/src/App.js'
});
case 6:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
})));
test('find an inline source map', _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
var sourceName, file, fileO, sm;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
sourceName = 'test.js';
file = fs.readFileSync(resolve(__dirname, '../../fixtures/inline.mjs')).toString('utf8');
fileO = fs.readFileSync(resolve(__dirname, '../../fixtures/inline.es6.mjs')).toString('utf8');
_context2.next = 5;
return getSourceMap('/', file);
case 5:
sm = _context2.sent;
expect(sm.getSources()).toEqual([sourceName]);
expect(sm.getSource(sourceName)).toBe(fileO);
expect(sm.getGeneratedPosition(sourceName, 5, 10)).toEqual({
line: 10,
column: 8
});
case 9:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})));
test('error on a source map with unsupported encoding', _asyncToGenerator(_regeneratorRuntime.mark(function _callee3() {
var file;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
expect.assertions(2);
file = fs.readFileSync(resolve(__dirname, '../../fixtures/junk-inline.mjs')).toString('utf8');
_context3.prev = 2;
_context3.next = 5;
return getSourceMap('/', file);
case 5:
_context3.next = 11;
break;
case 7:
_context3.prev = 7;
_context3.t0 = _context3['catch'](2);
expect(_context3.t0 instanceof Error).toBe(true);
expect(_context3.t0.message).toBe('Sorry, non-base64 inline source-map encoding is not supported.');
case 11:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this, [[2, 7]]);
})));

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { getLinesAround } from '../utils/getLinesAround';
var arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'];
test('should return lines around from a string', function () {
expect(getLinesAround(4, 2, arr)).toMatchSnapshot();
});
test('should return lines around from an array', function () {
expect(getLinesAround(4, 2, arr.join('\n'))).toMatchSnapshot();
});

View File

@@ -0,0 +1,113 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
var _this = this;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { map } from '../utils/mapper';
import { parse } from '../utils/parser';
import fs from 'fs';
import { resolve } from 'path';
test('basic error; 0 context', _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var error, frames;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
expect.assertions(1);
error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)\n at http://localhost:3000/static/js/bundle.js:30091:25\n at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:29901:12)\n at http://localhost:3000/static/js/bundle.js:30090:11\n at CallbackQueue.notifyAll (http://localhost:3000/static/js/bundle.js:13256:22)\n at ReactReconcileTransaction.close (http://localhost:3000/static/js/bundle.js:35124:26)\n at ReactReconcileTransaction.closeAll (http://localhost:3000/static/js/bundle.js:7390:25)\n at ReactReconcileTransaction.perform (http://localhost:3000/static/js/bundle.js:7337:16)\n at batchedMountComponentIntoNode (http://localhost:3000/static/js/bundle.js:14204:15)\n at ReactDefaultBatchingStrategyTransaction.perform (http://localhost:3000/static/js/bundle.js:7324:20)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:33900:26)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:2181:27)\n at Object._renderNewRootComponent (http://localhost:3000/static/js/bundle.js:14398:18)\n at Object._renderSubtreeIntoContainer (http://localhost:3000/static/js/bundle.js:14479:32)\n at Object.render (http://localhost:3000/static/js/bundle.js:14500:23)\n at Object.friendlySyntaxErrorLabel (http://localhost:3000/static/js/bundle.js:17287:20)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at fn (http://localhost:3000/static/js/bundle.js:84:20)\n at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:41219:18)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at validateFormat (http://localhost:3000/static/js/bundle.js:709:39)\n at http://localhost:3000/static/js/bundle.js:712:10';
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs')).toString('utf8'));
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs.map')).toString('utf8'));
_context.next = 6;
return map(parse(error), 0);
case 6:
frames = _context.sent;
expect(frames).toEqual(JSON.parse(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.json')).toString('utf8')));
case 8:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
})));
test('default context (3)', _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
var error, frames;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
expect.assertions(1);
error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)';
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs')).toString('utf8'));
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle.mjs.map')).toString('utf8'));
_context2.next = 6;
return map(parse(error));
case 6:
frames = _context2.sent;
expect(frames).toEqual(JSON.parse(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle-default.json')).toString('utf8')));
case 8:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})));
test('bad comes back same', _asyncToGenerator(_regeneratorRuntime.mark(function _callee3() {
var error, orig, frames;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
expect.assertions(2);
error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (A:1:2)';
orig = parse(error);
expect(orig).toEqual([{
_originalColumnNumber: null,
_originalFileName: null,
_originalFunctionName: null,
_originalLineNumber: null,
_originalScriptCode: null,
_scriptCode: null,
columnNumber: 2,
fileName: 'A',
functionName: 'App.componentDidMount',
lineNumber: 1
}]);
_context3.next = 6;
return map(orig);
case 6:
frames = _context3.sent;
expect(frames).toEqual(orig);
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this);
})));

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { parse } from '../../utils/parser';
test('stack with eval', function () {
expect(parse('TypeError: window[f] is not a function\n at e (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:18)\n at eval (eval at c (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:12:9), <anonymous>:1:1)\n at a (file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:9)\n at file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:7')).toMatchSnapshot();
});

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { parse } from '../../utils/parser';
test('eval 1', function () {
expect(parse('test1@file:///C:/example.html line 7 > eval line 1 > eval:1:1\ntest2@file:///C:/example.html line 7 > eval:1:1\ntest3@file:///C:/example.html:7:6'.split('\n'))).toMatchSnapshot();
});
test('eval 2', function () {
expect(parse({
stack: 'anonymous@file:///C:/example.html line 7 > Function:1:1\n@file:///C:/example.html:7:6'
})).toMatchSnapshot();
});
test('stack with eval', function () {
expect(parse('e@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:9\n@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html line 17 > eval:1:1\na@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:9\n@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:7')).toMatchSnapshot();
});
test('v14 to v29', function () {
expect(parse('trace@file:///C:/example.html:9\nb@file:///C:/example.html:16\na@file:///C:/example.html:19\n@file:///C:/example.html:21')).toMatchSnapshot();
});
test('v30+', function () {
expect(parse('trace@file:///C:/example.html:9:17\nb@file:///C:/example.html:16:13\na@file:///C:/example.html:19:13\n@file:///C:/example.html:21:9')).toMatchSnapshot();
});

View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { parse } from '../../utils/parser';
test('throws on null', function () {
expect.assertions(2);
try {
parse(null);
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe('You cannot pass a null object.');
}
});
test('throws on unparsable', function () {
expect.assertions(2);
try {
parse({});
} catch (e) {
expect(e instanceof Error).toBe(true);
expect(e.message).toBe('The error you provided does not contain a stack trace.');
}
});

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { parse } from '../../utils/parser';
test('15.y.z', function () {
expect(parse('Warning: Each child in array should have a unique "key" prop. Check render method of `FileA`.\n in div (at FileA.js:9)\n in FileA (at App.js:9)\n in div (at App.js:8)\n in App (at index.js:7)')).toMatchSnapshot();
});

View File

@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { parse } from '../../utils/parser';
test('stack with eval', function () {
expect(parse('e@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:25:18\neval code\neval@[native code]\na@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:8:10\nglobal code@file:///Users/joe/Documents/Development/OSS/stack-frame/index.html:32:8')).toMatchSnapshot();
});

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { ScriptLine } from '../utils/stack-frame';
test('script line shape', function () {
expect(new ScriptLine(5, 'foobar', true)).toMatchSnapshot();
});
test('script line to provide default highlight', function () {
expect(new ScriptLine(5, 'foobar')).toMatchSnapshot();
});

View File

@@ -0,0 +1,10 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
global.fetch = require('jest-fetch-mock');

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { StackFrame } from '../utils/stack-frame';
test('proper empty shape', function () {
var empty = new StackFrame();
expect(empty).toMatchSnapshot();
expect(empty.getFunctionName()).toBe(null);
expect(empty.getSource()).toBe('');
expect(empty.toString()).toBe('');
});
test('proper full shape', function () {
var empty = new StackFrame('a', 'b.js', 13, 37, undefined, 'apple', 'test.js', 37, 13);
expect(empty).toMatchSnapshot();
expect(empty.getFunctionName()).toBe('a');
expect(empty.getSource()).toBe('b.js:13:37');
expect(empty.toString()).toBe('a (b.js:13:37)');
});

View File

@@ -0,0 +1,87 @@
import _regeneratorRuntime from 'babel-runtime/regenerator';
var _this = this;
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import { unmap } from '../utils/unmapper';
import { parse } from '../utils/parser';
import fs from 'fs';
import { resolve } from 'path';
test('basic warning', _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
var error, frames, expected;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
expect.assertions(2);
error = 'Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `B`. See https://fb.me/react-warning-keys for more information.\n in div (at B.js:8)\n in B (at A.js:6)\n in A (at App.js:8)\n in div (at App.js:10)\n in App (at index.js:6)';
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs')).toString('utf8'));
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs.map')).toString('utf8'));
_context.next = 6;
return unmap('/static/js/bundle.js', parse(error), 0);
case 6:
frames = _context.sent;
expected = JSON.parse(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle2.json')).toString('utf8'));
expect(frames).toEqual(expected);
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs')).toString('utf8'));
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs.map')).toString('utf8'));
_context.t0 = expect;
_context.next = 14;
return unmap('/static/js/bundle.js', expected);
case 14:
_context.t1 = _context.sent;
_context.t2 = expected;
(0, _context.t0)(_context.t1).toEqual(_context.t2);
case 17:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
})));
test('default context & unfound source', _asyncToGenerator(_regeneratorRuntime.mark(function _callee2() {
var error, frames;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
expect.assertions(1);
error = 'Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `B`. See https://fb.me/react-warning-keys for more information.\n in div (at B.js:8)\n in unknown (at blabla.js:10)';
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs')).toString('utf8'));
fetch.mockResponseOnce(fs.readFileSync(resolve(__dirname, '../../fixtures/bundle_u.mjs.map')).toString('utf8'));
_context2.next = 6;
return unmap('/static/js/bundle.js', parse(error));
case 6:
frames = _context2.sent;
expect(frames).toMatchSnapshot();
case 8:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this);
})));