maty21 / mocha-sidebar

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)
MIT License
190 stars 61 forks source link

Mocha sidebar didn't recognize outer scope variables between items #153

Open lwxbr opened 6 years ago

lwxbr commented 6 years ago

Description

This image explains it all:

debug

Steps to Reproduce

const chai = require('chai');
const should = chai.should();

var x;

describe('Mocha', () => {

    describe('Testing mocha', function(){

        it('Task 1', (done) => {

            x = 42;
            done();
        });

        it('Task 2', (done) => {
            x.should.equal(42);
            done();
        });

        it('Task 3', (done) => {
            done();
        });

    });
});

Expected Results

expected

Actual Results

Running mocha using cli is working properly, only with mocha sidebar isn't:

npx mocha .\00-mocha.js

Settings file

   "mocha.files.glob": "./src/server/test/**/*.js",
    "mocha.options": {
        "exit": true,
        "timeout": 5000,
        "bail": true,
        "check-leaks": true,
        "globals": "x"
    }

Versions

OS version

maty21 commented 6 years ago

Hi I'll try my best to figure out what is the problem . I have a lot of pressure right now at the work but I'll find time soon for debugging it sry for the delay

maty21 commented 6 years ago

when you run mocha in debug mode. each test runs separately therefore if you change something in a different test it will not affect the current test (related for the mocha API via code ) a workaround for this issue is debug it by debugging it for the Tests root. btw there is already an open feature request for this screenshot from 2018-10-22 10-36-06

lwxbr commented 5 years ago

Thanks for info , @maty21! Yes, I can guess why the tasks can't share data between them. They are not called unit tests for nothing.