Default mocha configuration when using test panel to run individaul tests

Hi,

I'm probably just missing something here, but is there a way to control the default options for mocha when a run configuration is generated to run an individual test / suite from the test panel?

My project is in typescript, so I need a typescript compile step (+ a custom npm script step) and then I need the tests to execute from the typescript built artefacts directory. This works fine in the mocha run configuration that I have built myself, but if I use the quick run option to re-run an individual test from the test panel, it generates a run configuration of its own for that test, which does not execute the test from the built artefacts directory, nor even include the typescript compile step.

Is there a way to make these generated run configurations somehow "inherit" from the main mocha run configuration?

It can work around it by editing my main mocha run configuration to run the individual test I'm interested in, but if I could get the test panel quick run options working that would be great.

Thanks

1
5 comments

Generated run configurations inherit from the default run configuration, so you can try editing the default mocha configuration accordingly:

- in Run | Edit configurations, expand Defaults node, select Mocha

- modify default Mocha run configuration to match your setup

1

Thanks for your reply.

I tested this, but unfortunately it doesn't fix my problem.

The issue is that when the run configuration is generated, the mocha config is set to run an individual test (the "Test" radio button is selected) and the "Test file" is then filled out with an absolute path to the js file containing the test. This is the path to the "source" file, the file before it has been through the TypeScript compiler, which will copy the js file into a "build" dir.

When the run config is invoked, the "Test file" is passed to mocha, and so it loads the js file from the source dir, instead of the build dir, which fails due to missing dependencies (as the source dir doesn't contain the necessary built files from the TypeScript files).

Editing the default Mocha config doesn't seem to allow me to make the generated run configurations refer to the output files in the build dir. Even if I change the "Working directory" option, as an absolute path to the "Test file" is set, it has no effect.

Thanks

1

You have to generate run configuration from the generated js file right-click menu then, or create configurations manually

-1
Avatar
Permanently deleted user

This seems to be a bug.

If you make changes to the default Mocha config, it loses that config over a restart.

This is not what you necessarily would expect, and other configs are persisted. The Gradle config works as expected.

1

Please sign in to leave a comment.