UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

144 lines (87 loc) 5.87 kB
{@img images/browserstack.png} Integration with BrowserStack cloud-testing infrastructure ========================================================== Most of the web projects supports all major browsers. When aiming for the full certainty, about the quality of the product in every supported browser, a logical step is to run the test suite in all those browsers. Counting Chrome, Firefox, Safari, Edge - thats at least 4x of the single test suite launch, so for the single-machine setup, the workload can quickly become extremely intense. One way to solve this bottleneck is to maintain a farm of virtual machines with various OS/browser combinations. This can be tricky and will consume lots of your time and resources. Another, more elegant way is to use services providing the same infrastructure in the cloud. Thanks to services such as [BrowserStack](http://www.browserstack.com/) it is now very simple. Authentication -------------- When registering in BrowserStack, you will receive a user name and an access key. You can find these in your BrowserStack account under "Account -> Automate" section. Later in this guide we will refer to these as "BrowserStack username" and "BrowserStack access key" Quick testing ------- All you need to launch your test suite in the cloud is to sign up for the BrowserStack trial and run the following command: __SIESTA_DIR__/bin/webdriver http://localhost/my/siesta/project/wrapper.html --browserstack BS_USERNAME,BS_KEY --cap browser=firefox --cap os=windows --cap os_version=XP That's all, the only difference from a normal Siesta automated launch is the `--browserstack` option, which is a shortcut performing a few additional actions. We'll examine what happens under the hood later in this guide. Note how we have specified the desired OS/browser combination using the `--cap` switch (it specifies remote webdriver capability). For a full list of supported capabilities please refer to <http://www.browserstack.com/automate/capabilities> Parallelization --------------- When using cloud-based infrastructure, each test page is running inside of the own VM, which guarantees the exclusive focus owning and allows us to run several test pages in parallel. Naturally, that speed ups the test execution, by the number of parallel sessions we can run. This can be done using the `--max-workers` option, that specifies the maximum number of parallel sessions. Under the hood ------------- Let's examine what happens under the hood when we use the `--browserstack` shortcut option. In fact, we don't have to use this shortcut option and can perform all the steps listed below manually. 1) The first thing that happens is that Siesta establishes a local tunnel from your machine to the BrowserStack server, using the BrowserStack binaries. You can do this step manually by using the batch file in the Siesta package: __SIESTA_DIR__/bin/browserstacklocal --key BS_KEY When launched successfully, you should see the following text: Verifying parameters Starting local testing You can now access your local server(s) in our remote browser: http://local:80 Press Ctrl-C to exit 2) The "--host" option is set to point to the BrowserStack server, based on your username and access key: --host="http://BS_USERNAME:BS_KEY@hub.browserstack.com/wd/hub" 3) The browserstack specific capability "browserstack.local" is set to "true" To sum up, instead of using the `--browserstack` shortcut option, we could: - launch the tunnel manually: __SIESTA_DIR__/bin/browserstacklocal --key BS_KEY - specify the command as: __SIESTA_DIR__/bin/webdriver http://localhost/my/siesta/project/wrapper.html --host="http://BS_USERNAME:BS_KEY@hub.browserstack.com/wd/hub" --cap browser=firefox --cap os=windows --cap os_version=XP --cap browserstack.local=true For convenience, instead of setting the `--host` option manually, one can specify `--browserstack-user` and `--browserstack-key` options. __SIESTA_DIR__/bin/webdriver http://localhost/myproject/tests/project.html --browserstack-user=BS_USERNAME --browserstack-key=BS_KEY --cap browser=firefox --cap os=windows --cap os_version=XP --cap browserstack.local=true Shared tunnel ------------- To share the tunnel to BrowserStack between the tests launches (saves the tunnel up/down time, convenient during development), use the `--browserstack_` option, which does the same things as `--browserstack` but uses existing tunnel. Then you'll need to launch the tunnel manually: __SIESTA_DIR__/bin/browserstacklocal --key BS_KEY Conclusion ---------- As you can see, thanks to the excellent [BrowserStack](http://www.browserstack.com) infrastructure, launching your tests in the cloud is as easy as specifying one extra argument on the command line. The benefits of cloud testing are obvious - no need to waste time and resources setting up and maintaining your own VM farm, and additionally you can run your test suite in various browsers in parallel. See also: --------- <http://www.browserstack.com/local-testing> Buy this product --------- Visit our store: <https://bryntum.com/store/siesta> Support --------- Ask a question in our community forum: <https://www.bryntum.com/forum/viewforum.php?f=20> Subscribers can post expedited questions in Premium Forum: <https://www.bryntum.com/forum/viewforum.php?f=21> Please report any bugs through the web interface at <https://www.assembla.com/spaces/bryntum/support/tickets> See also --------- Siesta web-page: <https://bryntum.com/products/siesta> Other Bryntum products: <https://bryntum.com/products> COPYRIGHT AND LICENSE --------- Copyright (c) 2009-2022, Bryntum AB & Nickolay Platonov All rights reserved.