microsoft / nodejstools

Node.js Tools for Visual Studio
http://aka.ms/explorentvs
Apache License 2.0
1.8k stars 358 forks source link

vstest config testrun parameters and mocha ? #1480

Open fforjan opened 7 years ago

fforjan commented 7 years ago

Hey guy,

Is it possible to get the vstest config test run parameters to mocha via environment variables ?

I'm interested to configure some test settings for our integration tests done via mocha - end points or number of retries globally. Our tests are currently working via environment variables.

paulvanbrenk commented 7 years ago

Not sure what you mean by that, can you give me an example.

fforjan commented 7 years ago

Sure, the scenario is this one: We're using mocha/JS tests for our integration testing. One of the feature we are using from mocha is retry but should be used on the build machine, not on a developer machine. One other configuration setting could be the endpoint for a sql database (localhost on a developer machine, instance on different computer while running on the build machine)

If I simplify a lot, our code look like this :

if(process.ENV.MochaRetryCount) {
   this.retry(process.ENV.MochaRetryCount);
}

and retry is https://mochajs.org/#retry-tests

because the only way I know to pass parameter to a test run with mocha is environment variable.

Now, while using vstest, you can use test run parameters, see : https://msdn.microsoft.com/en-us/library/jj635153.aspx

Is there a way to expose vstest run parameters to Mocha ? If not, what would be the best way, while running the test on a TFS build to enable parameters from the build definition ?

paulvanbrenk commented 7 years ago

Thanks for the clarification.