0

My goal is to set up an environment where CircleCI would run my e2e tests on BrowserStack in different browsers.

My tests are assuming that there is a mock server running. (E.g. tests are checking whether a certain call to the mock server has been made or not.)

I learned that there is such a thing as local testing for BrowserStack, but whenever I'd like to start the mock server on port 65432 it says the port is already being used. Error: listen EADDRINUSE :::65432

I have an Express mock server running (on port 65432), tests are ran by Nightwatch against Selenium server.

So far I only saw examples which run tests against homepages which are living on the internet (like google.com), but I would like to run my own mock server locally and run my tests against it.

Is there a way where I could run a mock server and run my tests with Nightwatch and Selenium against that mock server and all done by a CI tool running the tests on BrowserStack?

Adam Nagy
  • 77
  • 10

2 Answers2

0

If you have a internal website (not accessible to public) hosted on your machine (using mock server - Tomcat, Nginx, Express Mock Server, etc) and wish to run the Selenium based scripts to test that application on BrowserStack, then you can use the Local Testing feature.

You simply need to run the binary file that they provide on your local machine (where the internal website is accessible) and set the capability 'browserstack.local' to 'true'. Hence the tests running on BrowserStack will be able to access your internal website. I would recommend you to review the documentation here. You can checkout the documentation on NightwatchJS-BrowserStack here.

If you wish to trigger the tests using CircleCI. They provide the plug-in for CircleCI as well, read more on the same here. The plug-in itself will handle the Local Testing for you in that case.

Xtraterrestrial
  • 651
  • 1
  • 6
  • 12
  • thx @ckzgraphics for your answer, the [Local Testing Internals](https://www.browserstack.com/local-testing-internals) link helped me a lot to get a better understanding, however my problem was a bit different. – Adam Nagy Aug 29 '18 at 07:13
0

For future readers: my problem was parallelism - I set 2 workers (child processes basically) with the following object:

"test_workers": {
    'enabled': true,
    'workers': 2
}

I found this setup from one of the examples which I can't find anymore, but if you are running your Nightwatch tests with your own mock server this might mess up the test suite since every worker will try to spin up a mock server for it's own tests, which will obviously fail.

Adam Nagy
  • 77
  • 10