mocha-sidebar: Cannot run mocha-sidebar with typescript ts-node

Hi there,

I’m just trying out this package. But when I try to run the tests using mocha sidebar it just doesn’t read show my tests.

In the output tab I get this Finding tests with Mocha on Node.js at “/usr/bin/node” And I also get the error Mocha sidebar: Process exited with code 1. See Mocha output for more info.

My workspace settings look like this:

"mocha.files.glob": "src/**/*.spec.ts", "mocha.options": { "compilers": { "ts": "ts-node/register" } }, "mocha.requires": [ "ts-node/register" ], "mocha.runTestsOnSave": "true"

I have typescript installed locally I have all my unit tests under src directory.

Is there any docs I can refer to for Typescript setup with ts-node?

Thanks Ahmad

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 41 (15 by maintainers)

Most upvoted comments

hi @ahmadkhudeish
It works for me with these settings: "mocha.options": { "compilers": "ts-node/register" }, "mocha.requires": [ "ts-node/register" ], "mocha.files.glob": "test/*.test.ts"

i just uninstall, and reintall it , it work! this is my config

    "mocha.files.glob": "test/**/*.ts",
    "mocha.requires": [
        "ts-node/register"
    ],
    "mocha.options": {
        "compilers": {
            "ts": "ts-node/register"
        }
    }

Hello, How can I solve this problem? https://stackoverflow.com/q/68004071/1817640

@maty21

"ts-node": "^7.0.0",

Additionally, I removed the options section from the settings so all I have left is: { "mocha.files.glob": "**/*.spec.ts", "mocha.requires": [ "ts-node/register" ], }

Uninstalled and reinstalled the sidebar but still nothing. Sorry.

Do my best to fix it for you guys in this week

On Tue, Jul 17, 2018, 5:47 AM sparky.dasrath notifications@github.com wrote:

All I am also having the same issue as outlined above. In my .vscode folder, I created a settings.json which generated a ton of settings stuff. The workspace tab was empty and I added what @zengming00 https://github.com/zengming00 has but changed to fit my project:

{ “mocha.files.glob”: “test/**/*.spec.ts”, “mocha.requires”: [ “ts-node/register” ], “mocha.options”: { “compilers”: { “ts”: “ts-node/register” } } }

I have a very simple test called app.spec.ts located at test/ts/app.spec.ts. Even with the settings above, I do not get the gitlens hit to run all tests and my sidebar is blank. I even tried a reinstall of the plugin but no dice.

in the sidebar-mocha output I get:

`trying to searching for tests using these settings:

mocha path: mocha test files location: test//.ts files to ignore: /.git//,/node_modules/**/* environmets: {} requires: [“ts-node/register”] options: {“compilers”:{“ts”:“ts-node/register”}}

` I am not sure why mocha.files.glob and test files location do not match.

I was able to get mocha running via a gulp task, but getting the sidebar setup would be excellent. This thread is the closest I have come across that seems to have a working answer. Any assistance will be greatly appreciated.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maty21/mocha-sidebar/issues/61#issuecomment-405442430, or mute the thread https://github.com/notifications/unsubscribe-auth/AE_nuZeFR_Q7waS75FkYnmfIMp3N7os6ks5uHVBPgaJpZM4SEmow .

It took me a while but I got it running.

I have no idea what was wrong, actually, but in the end my config is:

"mocha.files.glob": "**/*.spec.ts",
	"mocha.requires": [
		"ts-node/register"
    ],

I think what did the trick was no specifying the directory in mocha.files.glob, instead, going directly with the recursion.

@PandaWood you can see the test result in the output if you set mocha.logVerbous to true in the settings