Coder Social home page Coder Social logo

maty21 / mocha-sidebar Goto Github PK

View Code? Open in Web Editor NEW
192.0 9.0 61.0 71.58 MB

Mocha side bar viewer that allows you to run Mocha tests from side bar menu and view results can run each level hierarchy from all tests to a single test(and each describer of course)

License: MIT License

JavaScript 99.91% TypeScript 0.09%

mocha-sidebar's Introduction

Mocha Side Bar

Version Installs Ratings Github Stars Gitter chat

Sidebar (new running in the new test view by default)

Demo showing mocha menu operation

Expect error messages (similar to wallaby implementation)

Demo that showing expect messages

coverage (via istanbul) soon as independent extension also

Demo that showing code coverage

NEW run test in parallel

Demo that showing parallel

* Important Note for coverage feature - there is an open issue in vscode that its not able to select via mouse / render two different decorations at the same line. as a workaround try F9/ or hide show decoration by clicking on the status bar

Mocha side bar is the most complete extension for mocha testing based on not maintained mocha extension and supports all of its features and much more

Love this extension? Star us and rate us!

Mocha Side Bar already supports these features (feel free to propose new features)

  • New code coverage support
  • see all tests in vscode side bar menu
  • git lens for running/debugging directly form the code
  • decorations which shows test status(pass/fail/not run) from code
  • run tests for each level hierarchy from all tests to a single test(and each describer of course)
  • debug tests for each level hierarchy from all tests to a single test(and each describer of course)
  • auto run tests on file save
  • see tests results directly on the code
  • run/debug results directly from the code
  • see test errors as decoration
  • add context menu on folders in explorer to set subdirectory (#2).
  • NEW run test in parallel (#162)

Not supported yet

  • tree view files separation hierarchy for the top level hierarchy

Known issues

  • Coverage- there is an open issue in vscode that its not able to select via mouse / render two different decorations at the same line. as a workaround try F9/ or hide show decoration by clicking on the status bar
  • Workspace - Currently not supported there is a workaround for solving it for more details #107

Collaborators:

  • Maty Zisserman
  • Yehiyam Livneh

Contributors

  • townbully

Contributions

Love this extension? Star us and rate us!

Want to make this extension even more awesome? Send us your wish.

Hate how it is working? File an issue and let us know.

FAQ

Q: Mocha Side Bar won't run?

A: Try the following:

  1. Verify that there is no other mocha runner extension on your machine.
  2. In case you're using test view option verify that the test view is already selected
  3. Make sure that mocha.logVerbose is set to true and Check logs in the output menu.
  4. Verify that the glob pattern is OK. The default is test/**/*.js
  5. Verify that you're not running with an old node version. 6.* should work.
  6. Try reinstall your VC Code instance
  7. Ask for our support on gitter Gitter chat

Q: I can't run TypeScript (ts-node compiler)

A: Try the following

  1. Try installing typescript and ts-node package locally (not with -g option)
  2. Verify that you're using ts-node that support import. Version 7.0.0 should work.
  3. Verify that your configuration is correct
"mocha.requires": [
    "ts-node/register"
],
  1. If you're still having problems you can try running TypeScript test typeScript-test on your machine.

Q: I can't run babel-register compiler

A: Verify that your configuration is correct

"mocha.requires": [
    "babel-register"
]

Q: I can't check breakpoints when coverage is running.

A: Try the following:

  1. Try F9 - That is an vscode issue that its not able to select/render two different decoration in the same place.
  2. You can enable disable coverage decoration by clicking on the status bar so you can open it only if its matter.

Q: Run all tests not working.

A: Verify that there is no describe or test with the name "test" (should be fix soon)


Q: Mocha Sidebar is not working on Windows with WSL (Error: Cannot find Node.js installation from environment variable)

A: Update your PATH in ~/.profile to PATH="$HOME/bin:$HOME/.local/bin:/usr/bin:$PATH" + restart VS Code (read more about this here: https://stackoverflow.com/a/44450219/1782659)


Q: im getting permision denied for coverage feature

A: try the follows

 cd ~/.vscode/extensions/maty.vscode-mocha-sidebar-0.20.22/
 chmod +x node_modules/nyc/bin/nyc.js node_modules/nyc/bin/wrap.js node_modules/mocha/bin/mocha

If for some reason something is not working for you can file an issue.

Fit yourself

No one shoe could fit everyone. You may need to turn some switches on to fit your project. Please file us an issue if you think there is a better way to fit you and the others.

Mocha options

Config description default
mocha.showInExplorer mocha view is now shown in the new test view as default it possible to switch it back to the explorer view with this setting "mocha.showInExplorer":false
mocha.options Options to run Mocha {}
mocha.files.glob Globs to use when searching for test files test/**/*.js
mocha.files.ignore Globs to ignore when searching for test files "mocha.files.ignore": [ "**/.git/**/*", "**/node_modules/**/*" ],
mocha.env Environment variables to run your tests "false"
mocha.path set other mocha path then the built-in one only path to mocha package ../node_modules/mocha "../node_modules/mocha"
mocha.logVerbose set mocha side bar log verbose for seeing in the output there are to different output sidebar-mocha for seeing mocha output and sidebar-coverage for seeing coverage output true
mocha.parallelTests run mocha tests in parallel 1

SideBar options

template

"mocha.sideBarOptions": {
            "lens": true, 
            "decoration": true,
            "autoUpdateTime": 2000,
            "showDebugTestStatus": true 
        }
Config description default
lens enable/disable lens - (the option to run/debug tests inside the code) by selecting true ro false true
decoration enable/disable decoration(the option to see test result status inside the code ) by selecting true ro false true
autoUpdateTime set timeout (in milliseconds) between each decorations and lens updates during test writing by selecting true ro false 2000
showDebugTestStatus an option to disable running mocha twice in order to see status on the sidebar true

Coverage options (soon will be independent package for this)

template

  "mocha.coverage": {
        
            "enable": true,
            "decoration": true,
            "runWithInterval": false,
            "autoUpdateInterval": 20000,
            "activeOnStart": true,
            "runAfterTest": false,
            "reporters": []
          },
     
Config description default
enable enable/disable coverage feature by selecting true ro false true
decoration enable/disable decoration(the option to see coverage result status inside the code ) true
runWithInterval auto coverage running false
autoUpdateInterval incase runWithInterval is enable that option allows you to decide on each interval coverage will run 20000
runAfterTest allows you to update coverage status after test running false
runCoverageAfterFileSave allows you to update coverage status after file save false
reporters allows you to add more reporters other than the default html text lcov []

Configuring Mocha options

Under File > Preferences > Workspace Settings, you can configure Mocha options, e.g. run in "tdd" mode, detect/ignore leaks, etc.

Usage via command Palette

To run Mocha tests:

  • Bring up Command Palette (F1, or Ctrl+Shift+P on Windows and Linux, or Shift+CMD+P on OSX)
  • Type or select "Mocha: Run all tests" You can run tests by:
  • All tests in the workspace
  • All or failed tests in last run
  • Tests that match a Regular Expression
  • Tests that the current cursor position (or the current file)
  • One test that you pick from a list

Demo showing Mocha test result

Setting a keyboard shortcut

To quickly run tests, you can create a keyboard shortcut under File > Preferences > Keyboard Shortcuts. For example, the following JSON will run all tests with CTRL+K followed by R key.

{
  "key": "ctrl+k r",
  "command": "mocha.runAllTests"
}

Following commands are also supported:

Command Title
mocha.runAllTests Mocha: Run all tests
mocha.runFailedTests Mocha: Run failed tests
mocha.runLastSetAgain Mocha: Run last set again
mocha.runTestAtCursor Mocha: Run tests matching the current cursor position or the current active file
mocha.runTestsByPattern Mocha: Run tests matching a pattern
mocha.selectAndRunTest Mocha: Select and run a test

How it works

By default, this extensions will discover tests by searching for test/**/*.js under your workspace.

Because your tests may requires a newer version of Node.js than the one powering Visual Studio Code, thus, this extension will attempt to find your installed Node.js and use it for your tests. It will search for the installed Node.js as indicated by environmental variable PATH. You can find the logic here.

When the test is being run, we will add NODE_PATH to point to your workspace node_modules folder to help resolving external modules.

When you ask to run the test under cursor position, the extension will parse the current file and look for matching tests or suites. If the file contains tests or suites defined using template strings or via dynamic generation, the regular expression (.+) will be used as a placeholder in order to have a better matching without having to evaluate the file twice. This implies that more tests than expected might be run.

mocha-sidebar's People

Contributors

adenflorian avatar alliesfriel avatar ankon avatar aritheelk avatar celador avatar dfischer avatar eramitmittal avatar immanuel192 avatar kendfrey avatar maty21 avatar pieterwillaert avatar scriptcoded avatar sportnak avatar svennergr avatar tomoyukiaota avatar townbully avatar yehiyam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mocha-sidebar's Issues

refresh not update lenses

on refresh we should create code lenses again but only after item
updated in order to prevent inconsistent behavior

Can't debug with Typescript

I can't debug with Typescript. I set a breakpoint and it seems to be ignored.

Here is my config:

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

"Test file(s): undefined"

Hi,

My test files show up in the sidebar, but when I try to Run All Tests I get the same type of error as in #13:

Running Mocha with Node.js at /Users/jeff/.nvm/versions/node/v8.9.1/bin/node

Applying Mocha options:
  {
    "ui": "bdd",
    "timeout": 10000,
    "recursive": true
  }

Test file(s):
  undefined
module.js:538
    throw err;
    ^

Error: Cannot find module '/Users/jeff/VSCode/api/src/undefined'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at /Users/jeff/.vscode/extensions/maty.vscode-mocha-sidebar-0.13.5/node_modules/mocha/lib/mocha.js:220:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/jeff/.vscode/extensions/maty.vscode-mocha-sidebar-0.13.5/node_modules/mocha/lib/mocha.js:217:14)
    at Mocha.run (/Users/jeff/.vscode/extensions/maty.vscode-mocha-sidebar-0.13.5/node_modules/mocha/lib/mocha.js:469:10)
    at Object.<anonymous> (/Users/jeff/.vscode/extensions/maty.vscode-mocha-sidebar-0.13.5/worker/runtest.js:63:7)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)

I have the following config in my User Settings:

    "mocha.options": {
        "ui": "bdd",
        "timeout": 10000,
        "recursive": true
    },
    "mocha.files.glob": "test/**/*.js",
    "mocha.files.ignore": [
        "test/fixtures/**/*"
    ],
    "mocha.env": {
        "BLUEBIRD_DEBUG": "1",
        "BLUEBIRD_W_FORGOTTEN_RETURN": "0",
        "JWT_KEY": "XXXXX"
    },
    "mocha.node_options": [
        "--trace-warnings"
    ]

I am able to run my tests from the command line using both nyc and mocha:

$ yarn run test
yarn run v1.3.2
$ JWT_KEY=XXXXX nyc mocha


debug: -------------------------------------------------------
debug: :: Thu Nov 16 2017 15:49:01 GMT-0800 (PST)
debug: Environment : development
debug: Port        : 18888
debug: -------------------------------------------------------
  Controller: AdminController
    Route: GET /admin/alive
      โœ“ should respond with an alive message

[ ... ]

  716 passing (9s)
  4 pending


=============================== Coverage summary ===============================
Statements   : 80.2% ( 3204/3995 )
Branches     : 67.07% ( 1167/1740 )
Functions    : 85.61% ( 595/695 )
Lines        : 80.84% ( 3131/3873 )
================================================================================
โœจ  Done in 11.05s.

But it seems like the files argument in worker.js is not being set correctly:

args.files.forEach(file => {

Any help would be appreciated!

Sidebar failed to load tests

I have mochajs project with bable transpiler.
When i install mocha-sidebar in vscode, tests are not showing up.
api-test(root folder)/smoke-test/smoke.js is my test location.
When I change test location to this, it give me error
"Mocha sidebar: Process exited with code 255. See Mocha output for more info."
when i check mocha output, it says Finding tests with Mocha on Node.js at "/usr/local/bin/node"
I have set my settings as
{"mocha.options": {
"compilers": {
"js": "./custom-babel-register.js"
}
},
"mocha.requires": [
"babel-polyfill"
],
"mocha.files.glob": "api-tests/smoke/*.js"
}

Use mocha options provided in Settings when debugging

Summary

We are still using the default args value for the path to the tests when we run tests in debug mode using the sidebar.

Origin

We are hardcoding the arguments we use when we run Mocha in debug mode as can be seen in the snippet:

~/.vscode/extensions/maty.vscode-mocha-sidebar-0.13.2/provider-extensions/runDebug.js

62|  callFunctionOnTerminate = functionOnTerminate.bind(_provider);
63|  mochaTest.args = ["./test/**/*.js"]

This above assignment of args is repeated for the methods debugLevel and debugItem as well.

Suggestion

Parse and use the options provided in the User/Workspace Settings file as the value for the argument to be used to run Mocha in debug mode.

bug: finding..

Finding tests with Mocha on Node.js at "C:\nodejs\node.EXE"

Typo

finish failuare amount:0
should be
finish failure amount:0
Proper capitalisation would also be nice.

Test file(s): undefined

Everything appears set up OK (VSCode on Debian) but sidebar isn't locating test files, when runs I am just seeing:

Running Mocha with Node.js at "/usr/local/bin/node"
Applying Mocha options:
{
"mocha.files.glob": "test/**/*.js"
}
Test file(s):
undefined

Is there any basic setup I am missing?

thanks

Debug Suite/Item fails when using TDD ui

When trying to debug suite or item by clicking on the lens link, the exception is thrown:

Exception has occurred: ReferenceError
ReferenceError: suite is not defined
at Object. (...\test.js:6:1)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at ....vscode\extensions\maty.vscode-mocha-sidebar-0.14.5\node_modules\mocha\lib\mocha.js:220:27
at Array.forEach ()
at Mocha.loadFiles (....vscode\extensions\maty.vscode-mocha-sidebar-0.14.5\node_modules\mocha\lib\mocha.js:217:14)
at Mocha.run (....vscode\extensions\maty.vscode-mocha-sidebar-0.14.5\node_modules\mocha\lib\mocha.js:469:10)
at Object. (....vscode\extensions\maty.vscode-mocha-sidebar-0.14.5\node_modules\mocha\bin_mocha:404:18)
at Module._compile (module.js:638:14)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)
at Function.Module.runMain (module.js:682:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:613:3

Running tests through lens links or running on save works. It seems the workspace mocha settings options are not passed in when debugging.
This only happens if TDD ui is used, if the default ui is used then the debugging works.

Is it possible to print out mocha error message into "output" area

I saw an error alert emitted in my usage today, but I didn't know why it alerted:

2017-12-23_22-30-45
Until I ran the original mocha command I saw the compiling error in the log through the terminal, which is actually also highlighted in the screenshot above.

So is it possible or is there any options I could use to make the mocha's original log or error messages could be brought out ?

location of run options in test source

The run/debug option that appears in the test source code is appearing in the wrong place. It works, but it shows on the wrong it. See the attached image, the upper it has 2x run options, and the lower it has NO run options.

image

Settings ignored: runTestsOnSave

Hi @maty21!

First of all, great work on this plugin!

I am having some issues with the test runner. When I save a .ts file, the mocha sidebar still runs the tests even though runTestOnSave is false. Here are my settings:

{
    // Mocha: Options to run Mocha
    "mocha.options": {
        "compilers": {
            "ts": "ts-node/register"
        }
    },
    // Mocha: Glob to search for test files
    "mocha.files.glob": "app/scenarios/**/*.scenario.ts",
    // Mocha: Globs to ignore when searching for test files
    "mocha.files.ignore": [
        "**/.git/**/*",
        "**/node_modules/**/*"
    ],
    //Mocha: run tests on each save
    "mocha.runTestsOnSave": "false",
    // Mocha: Environment variables to run your tests
    "mocha.env": {},
    // Mocha: Options to pass to node executable
    "mocha.node_options": [],
    // Mocha: Subdirectory in the Workspace where run mocha from
    "mocha.subfolder": "",
    // Mocha: List of files to require before running mocha
    "mocha.requires": [
        "ts-node/register"
    ],
    //Mocha: this option allows you to enable/disable lens decorations and set update threshold "
    "mocha.sideBarOptions": {
        
        "default": {
            "lens": true, // -> enable/disable lens
            "decoration": true, // -> enable/disable decoration
            "autoUpdateTime": 5000 // -> set timeout between each decorations and lens updates during test writing 
        }
    }
}

Test Runner Restarts

Version Info
mocha-sidebar: 0.14.20
mocha: 3.5.3

Problem:
When I have a test with multiple test cases (it(...)) in a describe function.

When I want to run a group of tests (describe) the plugin starts them all individually meaning that I lose all scope.

Expectation:
I would expect all test cases run inside a describe function to be executed in the same run and not to lose variable scope.

Example

describe('Scenarios', () => {

    // then run your test
    describe('Company Suggest Job', () => {

        let user: IdentityModel;
        let userToken: JwtEncodedModel;

        it('should create a user', inject([Done], (done: Done) => {

            let userData: any = {
                username: '[email protected]',
                password: 'Password123!'
            };

            SuperTest('http://localhost:9000')
                .put('/me/')
                .send(userData)
                .expect(200)
                .end((err, response: any) => {
                    if (err) {
                        throw (err);
                    }

                    let obj = JSON.parse(response.text);
                    expect(obj.id).to.not.be.undefined;
                    user = obj;
                    done();
                });
        }));

        it('should login as user', inject([Done], (done: Done) => {

            let loginData: any = {
                username: '[email protected]',
                password: 'Password123!',
                clientId: 'O7895v6bFs1fObkADKgW5RnMyjQr44Gt'
            };

            SuperTest('http://localhost:9000')
                .post('/auth/login/')
                .send(loginData)
                .expect(200)
                .end((err, response: any) => {
                    if (err) {
                        throw (err);
                    }

                    let obj = JSON.parse(response.text);
                    expect(obj.accessToken).to.not.be.undefined;
                    userToken = obj;
                    done();
                });
        }));

    });

});

mocha.requires (settings.json) is not taken into consideration when debuging a single test

When I run all my tests through a debug configuration like this:

        {
            "type": "node",
            "request": "launch",
            "name": "Debug Mocha Tests",
            "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
            "args": [
                "-u",
                "tdd",
                "--timeout",
                "10000",
                "--colors",
                "${workspaceFolder}/Tests/Mocha/Features",
                "--require",
                "${workspaceFolder}/config/local.js"
            ],
            "internalConsoleOptions": "openOnSessionStart"
        }

THEN the --require option is taken into consideration and I can debug the code inside config/local.js.

BUT when I open a single test file and inside the test I click on "Debug Item", then the config/local.js is not loaded.
How to I get my --require files to load before the test when clicking on "Debug item"?

In .vscode I have a settings.json file that looks like this:

{
    "mocha.files.glob": "tests/mocha/features/*.js",
    "mocha.options": {
        "timeout" : 10000
    },
    "mocha.requires": [
        "config/local.js"
    ]
}

I've read through the Q&A without any luck.

Thanks

Q: Is there a way to prevent the output window from activating?

Very happy to have discovered this project, and it's proved to be a good productivity tool.

The only slightly jarring thing, for me personally, is the constant activation and streams of text that appear in the output window. I tend to spend a lot of time in the terminal, and I have to keep switching back to that, only to have mocha-sidebar jump back to the output window.

As there are already indications in a sidebar, and inline in code, it would be great to have an option to disable output / or better still, an option to not automatically switch to the output window, allowing me to chose if I want it displayed or not. Perhaps I have missed an existing option to do so...?

Failed tests do not turn red if failure occurs in Mocha hooks

When an assertion fails in one of the Mocha hooks like before, beforeEach or afterEach, the corresponding test entry in the moca-sidebar does not turn red. Example:

describe("some test", () => {

  before(() => {
    // this assertion fails, but mocha-sidebar test entry does not turn red
    assert.equal(1, 2);
  });

  it("should pass", () => {

  });

});

Unexpected token import while debugging single test

I have the following in my settings.json

  // Mocha: Glob to search for test files
  "mocha.files.glob": "src/test/**/*.ts",

  // Array of module required to run Mocha. (for example babel-register, coffee-script/register or ts-node/register)
  "mocha.requires": [ "ts-node/register" ],

The mocha sidebar shows my tests and runs the just fine.
If I click on debug I get the following error:

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:607:28)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at C:\Users\user\.vscode\extensions\maty.vscode-mocha-sidebar-0.14.20\node_modules\mocha\lib\mocha.js:220:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (C:\Users\user\.vscode\extensions\maty.vscode-mocha-sidebar-0.14.20\node_modules\mocha\lib\mocha.js:217:14)
    at Mocha.run (C:\Users\user\.vscode\extensions\maty.vscode-mocha-sidebar-0.14.20\node_modules\mocha\lib\mocha.js:469:10)
    at Object.<anonymous> (C:\Users\user\.vscode\extensions\maty.vscode-mocha-sidebar-0.14.20\node_modules\mocha\bin\_mocha:404:18)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

In the debug console I can see the following command is executed:

node --inspect-brk=24297 ..\..\..\.vscode\extensions\maty.vscode-mocha-sidebar-0.14.20\node_modules\mocha\bin\_mocha src/test/**/*.ts --grep '^Hello function should return hello world$' 

As you can see, no arguments are passed to mocha. If I add --require ts-node/register the run works. How can I pass arguements to mocha while debugging a single test?

If I create a mocha.opts file a directory test with --require ts-node/register debugging will work. But that's not a good solution since my tests live in src/test/ not in test

How can I pass options to mocha?

Hi,
I have a codebase in typescript so usually I am running mocha with the parameter --compilers ts:ts-node/register

I saw you have a mocha.options parameter in this extension but and I tried a few things but cant get it to work.
"mocha.options": {
"compilers": {
"ts": "ts-node/register"
}
},
^ not working

Are these types of options supported?

Location of "requires"

Hi, I cannot make your extension work.
I need to require a setup file before mocha executes.
This file is located in the root of my project "mocha.js"

When I specify "mocha.requires": ["./mocha.js"] it is giving me error that .. "node_modules/./mocha.js" cannot be found. It seems that the search starts in node_modules for some reason. I tried myriads of combinations "mocha.js" .. "../mocha.js" .. nothing seems to work.

The situation is complicated even more that the project is typescript. Therefore my "mocha.files.glob" is "src/**/*.test.ts".

Any advice how can I make this work?
Thanks

How to run all tests with single trigger.

When I right click on Tests and click run all tests, I get exception with this stack trace

Test file(s):
  undefined
module.js:529
    throw err;
    ^

Error: Cannot find module '/home/user/dir1/dir2/dir3/undefined'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at /home/user/.vscode/extensions/maty.vscode-mocha-sidebar-0.10.0/node_modules/mocha/lib/mocha.js:220:27
    at Array.forEach ()
    at Mocha.loadFiles (/home/user/.vscode/extensions/maty.vscode-mocha-sidebar-0.10.0/node_modules/mocha/lib/mocha.js:217:14)
    at Mocha.run (/home/user/.vscode/extensions/maty.vscode-mocha-sidebar-0.10.0/node_modules/mocha/lib/mocha.js:469:10)
    at Object. (/home/user/.vscode/extensions/maty.vscode-mocha-sidebar-0.10.0/worker/runtest.js:57:7)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:201:16)

Blue dots not changing colour

Sometimes when tests fail the dots stay blue instead of turning red and after that it seems they don't go green even after fixing the tests until I restart vscode and re-run them.

Mocha Debug and Report Options

Hi, I have two questions about the mocha sidebar options.

  1. When I run this command at the Windows prompt, this works perfectly:
    npm mocha --ui bdd - reporter mocha-simple-html-reporter - reporter-output options = report.html

Ok, but when I use the mocha-sidebar in VS Code

Open User Settings:
File -> Preferences -> Settings (VS Code)

{
"mocha.options": {
"ui": "bdd",
"reporter": "mocha-simple-html-reporter"
}
}

ok, but how to configure "--reporter-options output = report.html"?

  1. When I run this command at the Windows prompt, this works perfectly:
    npm mocha --debug-brk

Ok, but when I use mocha-sidebar in VS Code

Open User Settings:
File -> Preferences -> Settings (VS Code)

{
"mocha.node_options": [
"debug"
]
}

Ok, there another option to configure "--debug-brk"?

Thanks for the advance.

Add License

Great extension! Could you add a license?

Better error output

I'm getting this in a project:

so it says there's an error, and to see the output, but the output is only shows that line ... nothing more.

How can I debug what's going on, so I can make this amazing extension to work? :)

BTW The extension is working on other projects on the same machine.

mocha-sidebar empty upon startup

Sometimes (not always) when I open vscode absolutely no tests show up in the sidebar. Clicking the refresh button does not help either.

After restarting vscode they show up again.

"mocha.subfolder" is missing? Is there an alternative?

My TypeScript project has a structure like this.
-- src/test (all TypeScript test files)
-- out/test (all JavaScript test files)
-- package.json

I suppose "mocha.subfolder" = "out/test" tells the sidebar where to find the tests. Howerver, this setting is not available anymore. What is the alternative?

P.S: To run tests manually, "mocha out/test --recursive" works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.