Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Cannot display real source code inside mocha #14

Open
wintercounter opened this issue Apr 3, 2017 · 1 comment
Open

Cannot display real source code inside mocha #14

wintercounter opened this issue Apr 3, 2017 · 1 comment

Comments

@wintercounter
Copy link

wintercounter commented Apr 3, 2017

I've got test-bed set up and it works quite well. I've wrote some tests using async/await. Unfortunately, it shows only the transpiled code in mocha. Then I added babel-plugin-istanbul to the project, and now I also get coverage's code in mocha.

Examples:

// IN
it('should play a beep', () => {
	sound.playSound();
	assert.isFalse(audioEl.paused, 'is not playing');
});

// OUT
++cov_2d2ry0wax2.f[4];
++cov_2d2ry0wax2.s[8];
sound.playSound();
++cov_2d2ry0wax2.s[9];
assert.isFalse(audioEl.paused, 'is not playing');

// IN
it('should have stopped', async () => {
	await stopPromise;
	assert.isTrue(audioEl.paused, 'is not stopped');
});

// OUT
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"); });

I've already tried to play around with the configs in createServer.js, nothing worked so far. Can someone please point me into the right direction?

Here is my webpack.config.test.js file: https://pastebin.com/SWzkDjwV

@dtinth
Copy link
Contributor

dtinth commented Apr 24, 2017

Unfortunately, Mocha uses fn.toString() to obtain the function’s body. This behavior is not customizable, which means Mocha will always show the transpiled source code. To make it display original source code requires complex instrumentation of the code, so I think it’s going to be hard to implement this.

I recommend using your browser’s dev tools to debug a test.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants