Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Each test case is runs in a separate node.js process #223

Closed
lukedgr opened this issue Jun 20, 2015 · 6 comments
Closed

Each test case is runs in a separate node.js process #223

lukedgr opened this issue Jun 20, 2015 · 6 comments

Comments

@lukedgr
Copy link
Member

lukedgr commented Jun 20, 2015

Copying issue from https://nodejstools.codeplex.com/workitem/1615

Selecting a subset or all the test cases to be run from the Test Explorer will make each test case to be run on it's own separate node.js process.

This leads to test hooks for the suite not being honored, as they are run for each test case, instead of for each test suite. For instance, on Mocha:

describe('myTestSuite', function(){
    before(function() {
        veryExpensiveOperation();
    });

    it('testCase1', function() { ... });
    it('testCase2', function() { ... });
});

If testCase1 and testCase2 are selected and run from test explorer, we would get the "before()" function called twice, essentially this makes the before() behaving like a beforeEach() (check out Mocha's page about hooks).

Ideally, the suite should be run on a single node.js process, so before() and after() method could be run only once per suite, allowing expensive code to be factored in a way that optimizes the execution time.

The issue is on the TestExecute.cs for the test adapter, on the RunTestCases() method. It iterates over all the test cases and calls RunTestCase() for each one of them. RunTestCase() spawns a new nodejs process and asks mocha to execute that specific test case received as argument.

@mousetraps
Copy link
Contributor

Yeah, we would make a lot of people happy if we fixed this one...

Thx for copying it over. I'll close the issue in codeplex and redirect to here.

@NoelAbrahams
Copy link

Is there any chance of adding this to an explicit milestone? The current mechanism of spinning off a separate node process is adding about 200 ms to every single test.

@SteveALee
Copy link

I've no idea if it's possible with Mocha but it would be great to support the standard TAP protocol in the VS runner for process / runner communication. For example see node-tap and I'm using tape which supports node and browsers. There's also npm TAP parser.

An advantage of TAP is there are lots of tools that support it. It's also mature (very).

@mousetraps
Copy link
Contributor

@SteveALee what do you mean by "support"? What functionality are you looking for? The default mocha reporter in ntvs is tap
b93b591

@SteveALee
Copy link

I was simply thinking that if the VS runner window and the processes it talks to both talk TAP then we have the ability to swap either for alternative. May not hold water on analysis though.

@paulvanbrenk
Copy link
Contributor

Closing as we no longer spin up a new instance of Node for each test, but re-use running instance. (This has been the case in v1.3 and every version of Visual Studio 2017).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants