Using the run/debug gutter icon on transpiled JavaScript

I am using TypeScript and JavaScript together in my project.

The source is in the src/ folder and the transpiled sources are in the dist/ folder.

I use mocha for my testing framework.

When I'm in the editor for src/someTest.js, the gutter shows the green double arrow which I can use to run/debug the test.

However, it doesn't work because it runs the tests from the src/ folder and not from the dist/ folder so it can't find/load other generated modules.

Is there some option to set Webstorm to run the transpiled sources (some way to specify the mapping) when I click on the gutter icon?

In the mean time I have some workarounds:

1) Navigate to dist/someTest.js to see the transpiled version and run/debug the test from there. Works but breaks the flow. Side question: is there some way to quickly navigate between the original source and the generated source (like jump to related file feature)

2) Create a dedicated launch configuration that specifies /dist. Works but it is troublesome to create one for each test/test method.

Any help would be appreciated.

 

7
11 comments

Is there some option to set Webstorm to run the transpiled sources (some way to specify the mapping) when I click on the gutter icon?

No, as there is no generic way to find the generated file from original one - there are dozens (actually - unlimited) ways to transform them. You can resolve original file from generated one using sourcemaps, but not vice versa.

Anyway, please vote for https://youtrack.jetbrains.com/issue/WEB-25389

Side question: is there some way to quickly navigate between the original source and the generated source (like jump to related file feature)

No; related feature request - https://youtrack.jetbrains.com/issue/WEB-24588.

0

~1.5 years later now.  In a team environment with many junior devs, it'd be nice if the gutter icons ran the tests using a configurable run/debug configuration, so that they can debug by right-clicking the gutter icon and have it Just Work™️.  The run/debug configuration used via the gutter icons should be configurable and stored in the project settings.  That way, everything but the .idea/workspace.xml can be stored in source control & the devs will have everything upon completion of git clone.

0

>it'd be nice if the gutter icons ran the tests using a configurable run/debug configuration

all auto-created  configuration are based on configuration templates that are configured in Run | Edit configurations.. | Templates and stored in .idea/workspace.xml

0

Hmm.  Does that mean that they're not sharable?  By all accounts I've seen, .idea/workspace.xml is the one file you're not supposed to put under source control...

0

@elena, are the templates configured in Run | Edit configurations... | Templates specific to the current project or are they global to the IDE?  I'm guessing specific to the project, but I'd like to be sure.

0

They are project-specific

0

Where do they originate from?  How do I add a new template as a copy of an existing one and share it with the rest of the team?

0

Default templates are hardcoded in plugins that provide them; once you change a template, it's saved in project workspace.xml

0

So, until they're no longer hardcoded, I guess the best I can do is customize one, then merge the xml into workspace.xml.  Right?

0

Please sign in to leave a comment.