cspotcode/vscode-mocha-latte

Allow usage with typescript

Opened this issue · 3 comments

Thanks for this fork!

Could you help me with using Mocha Latte with typescript?

Many thanks

Google and Stackoverflow are your friends for this one. If you have Mocha Latte bugs (not Mocha bugs) please file them here, but for general Mocha usage this isn't the best place to ask. I think there are several tutorials explaining how to use Typescript with Mocha.

@cspotcode thanks for your reply. Sorry, my question was a bit too vague/general. I can run mocha tests with typescript from terminal, without any issues. The problem I have with Mocha Latte is that it does not allow typescript files.

Here are screenshots to reproduce:
bildschirmfoto 2017-02-14 um 14 01 37

bildschirmfoto 2017-02-14 um 14 01 40

The issue is probably due to the following check: https://github.com/cspotcode/vscode-mocha-latte/blob/master/extension.js#L124

Any ideas how to fix this?

Thanks for the extra information. The problem is that "Run test at cursor" uses static code analysis to parse the Javascript, locate all the define() and it() calls surrounding your current cursor position and determine the test's name. It wasn't written to parse TypeScript, although someone could certainly update it to do so. This feature was added by @ShogunPanda in PR #2.

In the short-term, can you run your tests using Mocha Latte's other options? They don't use static code analysis so they should work well with TypeScript. I know they're not as convenient as "run at cursor."
screen shot 2017-02-14 at 12 20 49 pm

As far as resolving this issue properly, I think there are two options:

  1. rewrite / extend the parsing code to use TypeScript's compiler instead of the babylon parser. That way you can "run test at cursor" within TypeScript files. I'll merge a PR if someone writes it.
  2. Update the error messages to explain that only "Run at cursor" is incompatible with TypeScript. The other commands will work.