Skip to content

Commit

Permalink
Use "inline" source maps in the compiler (part of #1375) (#1376)
Browse files Browse the repository at this point in the history
* Use "inline" source maps in the compiler (part of #1375)

* fix regression test
  • Loading branch information
georgiy-abbasov authored and AlexanderMoskovkin committed Apr 6, 2017
1 parent 8695a04 commit b901d9e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 52 deletions.
11 changes: 3 additions & 8 deletions src/compiler/es-next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class ESNextCompiler {
],
filename: filename,
retainLines: true,
sourceMaps: true,
sourceMaps: 'inline',
ast: false,
babelrc: false,
highlightCode: false,
Expand Down Expand Up @@ -87,14 +87,9 @@ export default class ESNextCompiler {

_setupSourceMapsSupport () {
sourceMapSupport.install({
hookRequire: true,
handleUncaughtExceptions: false,
environment: 'node',

retrieveSourceMap: filename => {
var map = this.sourceMaps[filename];

return map ? { url: filename, map } : null;
}
environment: 'node'
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/errors/create-stack-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const TESTCAFE_LIB = join(__dirname, '../');
const TESTCAFE_BIN = join(__dirname, '../../bin');
const TESTCAFE_HAMMERHEAD = `${sep}testcafe-hammerhead${sep}`;

const SOURCE_MAP_SUPPORT = `${sep}source-map-support${sep}`;

const INTERNAL = 'internal/';

export default function createStackFilter (limit) {
Expand All @@ -34,7 +36,8 @@ export default function createStackFilter (limit) {
filename.indexOf(BABEL_RELATED) !== 0 &&
filename.indexOf(BABYLON) !== 0 &&
filename.indexOf(CORE_JS) !== 0 &&
filename.indexOf(REGENERATOR_RUNTIME) !== 0;
filename.indexOf(REGENERATOR_RUNTIME) !== 0 &&
filename.indexOf(SOURCE_MAP_SUPPORT) < 0;

if (pass)
passedFramesCount++;
Expand Down
16 changes: 16 additions & 0 deletions test/functional/fixtures/regression/gh-1267/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var expect = require('chai').expect;

describe('[Regression](GH-1267)', function () {
it('Incorrect callsite stack for failed assertion in a method of some class (GH-1267)', function () {
return runTests('testcafe-fixtures/index.test.js', null, { only: ['chrome'] })
.catch(function (errs) {
expect(errs[0]).to.contains(
' 3 |class Page {\n' +
' 4 | async expect (t) {\n' +
' > 5 | await t.expect(false).ok();\n' +
' 6 | }\n' +
' 7 |}\n'
);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fixture `gh-1267`;

class Page {
async expect (t) {
await t.expect(true).ok();
}
}

async function fn () {

}

test('test', async t => {
const page = new Page();

await page.expect(t);
await fn();
});
24 changes: 0 additions & 24 deletions test/server/compiler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,29 +453,5 @@ describe('Compiler', function () {
expect(stack[2].source).to.have.string('testfile.js');
});
});

it('Incorrect callsite stack for failed assertion in a method of some class (GH-1267)', function () {
return compile('test/server/data/test-suites/regression-gh-1267/testfile.js')
.then(function (compiled) {
return compiled.tests[0].fn(testRunMock);
})
.then(function () {
throw 'Promise rejection expected';
})
.catch(function (errList) {
var callsite = errList.items[0].callsite.renderSync({ renderer: renderers.noColor });

expect(callsite).to.contains(
' 13 |}\n' +
' 14 |\n' +
" 15 |test('test', async t => {\n" +
' 16 | const page = new Page();\n' +
' 17 |\n' +
' > 18 | await page.expect(t);\n' +
' 19 |});\n' +
' 20 |\n'
);
});
});
});
});
19 changes: 0 additions & 19 deletions test/server/data/test-suites/regression-gh-1267/testfile.js

This file was deleted.

0 comments on commit b901d9e

Please sign in to comment.