Skip to content

[Typescript] "Run test at cursor" command fails with "Mocha is only available for JavaScript files." #319

@ledenis

Description

@ledenis

Description

In a typescript project, Run test at cursor command fails with this notification message: "Mocha is only available for JavaScript files."

Steps to Reproduce

  1. Open a .spec.ts file
  2. Place cursor on a test
  3. Run the command with: Ctrl+Shift+P > "Mocha: Run test at cursor"

Expected Results

No error message and the test should run.

Actual Results

The notification message "Mocha is only available for JavaScript files." is shown and the test is not run.

Note: If I manually change the "Language Mode" to "JavaScript", it works, even if the file still contains typescript code!

Settings file

  "mocha.files.glob": "**/*.spec.ts",
  "mocha.options": {
    "config": "packages/services/my-api/.mocharc.unit.js"
  },
  "mocha.env": {
    "NODE_ENV": "test"
  },
  "mocha.requires": ["ts-node/register"],

Versions

  • VScode: v1.82.0
  • Mocha SideBar: v0.22.2
  • Node Version: v18.15.0

OS version

  • Linux
  • Mac
  • Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions