diff --git a/src/compiler/es-next/compile-client-function.js b/src/compiler/es-next/compile-client-function.js index 7dd232ad236..d26637064f8 100644 --- a/src/compiler/es-next/compile-client-function.js +++ b/src/compiler/es-next/compile-client-function.js @@ -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': { diff --git a/src/compiler/es-next/index.js b/src/compiler/es-next/index.js index 4dc08aa35e2..65dc068e975 100644 --- a/src/compiler/es-next/index.js +++ b/src/compiler/es-next/index.js @@ -38,10 +38,9 @@ export default class ESNextCompiler { return { passPerPreset: true, presets: [ - { plugins: transformRuntime }, { passPerPreset: false, - presets: [presetStage2, presetEnv] + presets: [{ plugins: [transformRuntime] }, presetStage2, presetEnv] } ], filename: filename, @@ -71,8 +70,8 @@ export default class ESNextCompiler { static _isNodeModulesDep (filename) { return relative(CWD, filename) - .split(pathSep) - .indexOf('node_modules') >= 0; + .split(pathSep) + .indexOf('node_modules') >= 0; } static _execAsModule (code, filename) { diff --git a/test/server/compiler-test.js b/test/server/compiler-test.js index e49660802ef..882ee0625e6 100644 --- a/test/server/compiler-test.js +++ b/test/server/compiler-test.js @@ -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' }; @@ -1320,8 +1321,6 @@ describe('Compiler', function () { describe('Regression', function () { it('Incorrect callsite line in error report on node v0.10.41 (GH-599)', function () { - this.timeout(5000); - var src = 'test/server/data/test-suites/regression-gh-599/testfile.js'; var compiler = new Compiler([src]); @@ -1341,5 +1340,43 @@ describe('Compiler', function () { expect(callsite).contains(' > 19 | .method1()\n'); }); }); + + it('Should successfully compile tests if re-export is used', function () { + var src = 'test/server/data/test-suites/regression-gh-969/testfile.js'; + var compiler = new Compiler([src]); + + return compiler + .getTests() + .then(function (tests) { + var test = tests[0]; + + return test.fn(testRunMock); + }); + }); + + it('Incorrect callsite stack in error report if "import" is used (GH-1226)', function () { + 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'); + }); + }); }); }); diff --git a/test/server/data/client-fn-compilation/typeof/expected-node10.js b/test/server/data/client-fn-compilation/typeof/expected-node10.js index 6c19773c049..184641e3258 100644 --- a/test/server/data/client-fn-compilation/typeof/expected-node10.js +++ b/test/server/data/client-fn-compilation/typeof/expected-node10.js @@ -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); }); })(); diff --git a/test/server/data/test-suites/regression-gh-1226/helper.js b/test/server/data/test-suites/regression-gh-1226/helper.js new file mode 100644 index 00000000000..bafbf9c567f --- /dev/null +++ b/test/server/data/test-suites/regression-gh-1226/helper.js @@ -0,0 +1,3 @@ +export default async function (t) { + throw new Error(); +} diff --git a/test/server/data/test-suites/regression-gh-1226/testfile.js b/test/server/data/test-suites/regression-gh-1226/testfile.js new file mode 100644 index 00000000000..f1cc82e104d --- /dev/null +++ b/test/server/data/test-suites/regression-gh-1226/testfile.js @@ -0,0 +1,8 @@ +import help from './helper.js'; + +fixture `Test` + .page `http://example.com`; + +test('test', async t => { + await help(t); +}); diff --git a/test/server/data/test-suites/regression-gh-969/helpers/consts.js b/test/server/data/test-suites/regression-gh-969/helpers/consts.js new file mode 100644 index 00000000000..e027273ee48 --- /dev/null +++ b/test/server/data/test-suites/regression-gh-969/helpers/consts.js @@ -0,0 +1 @@ +export const FOO = 42; diff --git a/test/server/data/test-suites/regression-gh-969/helpers/module.js b/test/server/data/test-suites/regression-gh-969/helpers/module.js new file mode 100644 index 00000000000..04cb42cb44a --- /dev/null +++ b/test/server/data/test-suites/regression-gh-969/helpers/module.js @@ -0,0 +1 @@ +export * from './consts' diff --git a/test/server/data/test-suites/regression-gh-969/testfile.js b/test/server/data/test-suites/regression-gh-969/testfile.js new file mode 100644 index 00000000000..720247563d0 --- /dev/null +++ b/test/server/data/test-suites/regression-gh-969/testfile.js @@ -0,0 +1,8 @@ +import { expect } from 'chai'; +import * as app from './helpers/module.js'; + +fixture('Export Issue'); + +test('re-export', async() => { + expect(app.FOO).to.eql(42); +}); \ No newline at end of file