Skip to content

Commit

Permalink
Changed babel options to avoid extra lines in report (closes DevExpre…
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgiy Abbasov committed Feb 13, 2017
1 parent 6372be8 commit 4acfc3e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/compiler/es-next/compile-client-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ANONYMOUS_FN_RE = /^function\*?\s*\(/;
const USE_STRICT_RE = /^('|")use strict('|");?/;
const TRAILING_SEMICOLON_RE = /;\s*$/;
const REGENERATOR_FOOTPRINTS_RE = /(_index\d+\.default|_regenerator\d+\.default|regeneratorRuntime)\.wrap\(function _callee\$\(_context\)/;
const ASYNC_TO_GENERATOR_OUTPUT_CODE = asyncToGenerator(noop).toString().replace(/\n\s*/g, '');
const ASYNC_TO_GENERATOR_OUTPUT_CODE = asyncToGenerator(noop).toString();

var babelArtifactPolyfills = {
'Promise': {
Expand Down
10 changes: 2 additions & 8 deletions src/compiler/es-next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ export default class ESNextCompiler {
// NOTE: passPrePreset and complex presets is a workaround for https://github.com/babel/babel/issues/2877
// Fixes https://github.com/DevExpress/testcafe/issues/969
return {
passPerPreset: true,
presets: [
{ plugins: transformRuntime },
{
passPerPreset: false,
presets: [presetStage2, presetEnv]
}
],
presets: [presetStage2, presetEnv],
plugins: [transformRuntime],
filename: filename,
sourceMaps: true,
retainLines: true,
Expand Down
54 changes: 41 additions & 13 deletions test/server/compiler-test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
var expect = require('chai').expect;
var resolve = require('path').resolve;
var sep = require('path').sep;
var readFile = require('fs').readFileSync;
var Promise = require('pinkie');
var stackParser = require('error-stack-parser');
var stripAnsi = require('strip-ansi');
var sortBy = require('lodash').sortBy;
var renderers = require('callsite-record').renderers;
var ERR_TYPE = require('../../lib/errors/test-run/type');
var Compiler = require('../../lib/compiler');
var commonAPI = require('../../lib/api/common');
var NODE_VER = require('../../lib/utils/node-version');
var expect = require('chai').expect;
var resolve = require('path').resolve;
var sep = require('path').sep;
var readFile = require('fs').readFileSync;
var Promise = require('pinkie');
var stackParser = require('error-stack-parser');
var stripAnsi = require('strip-ansi');
var sortBy = require('lodash').sortBy;
var renderers = require('callsite-record').renderers;
var ERR_TYPE = require('../../lib/errors/test-run/type');
var Compiler = require('../../lib/compiler');
var commonAPI = require('../../lib/api/common');
var NODE_VER = require('../../lib/utils/node-version');
var createStackFilter = require('../../lib/errors/create-stack-filter.js');

describe('Compiler', function () {
var testRunMock = { id: 'yo' };
Expand Down Expand Up @@ -1341,5 +1342,32 @@ describe('Compiler', function () {
expect(callsite).contains(' > 19 | .method1()\n');
});
});

it('Incorrect callsite stack in error report if "import" is used (GH-1226)', function () {
this.timeout(5000);

var src = 'test/server/data/test-suites/regression-gh-1226/testfile.js';
var compiler = new Compiler([src]);

return compiler
.getTests()
.then(function (tests) {
var test = tests[0];

return test.fn(testRunMock);
})
.then(function () {
throw 'Promise rejection expected';
})
.catch(function (err) {
var stackTraceLimit = 200;
var stack = err.callsite.stackFrames.filter(createStackFilter(stackTraceLimit));

expect(stack.length).eql(3);
expect(stack[0].source).to.have.string('helper.js');
expect(stack[1].source).to.have.string('helper.js');
expect(stack[2].source).to.have.string('testfile.js');
});
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
(function () {
var_typeof3 = {
default: function (obj) {
return typeof obj;
}
};
return (function () {
return typeof someObj === "undefined" ? "undefined" : _typeof(someObj);
return typeof someObj === "undefined" ? "undefined" : (0, _typeof3.default)(someObj);
});
})();
3 changes: 3 additions & 0 deletions test/server/data/test-suites/regression-gh-1226/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default async function (t) {
throw new Error();
}
8 changes: 8 additions & 0 deletions test/server/data/test-suites/regression-gh-1226/testfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import help from './helper.js';

fixture `Test`
.page `http://example.com`;

test('test', async t => {
await help(t);
});

0 comments on commit 4acfc3e

Please sign in to comment.