Skip to content

Instantly share code, notes, and snippets.

@yashLadha
Last active February 17, 2020 08:51
Show Gist options
  • Save yashLadha/11d28896f8401641254d38b50e397a3f to your computer and use it in GitHub Desktop.
Save yashLadha/11d28896f8401641254d38b50e397a3f to your computer and use it in GitHub Desktop.

Linking the plugin manually

Installing the plugin from github (Preffered way)

  1. cd into the project directory and install the package using
npm install --save-dev "DevExpress/testcafe-browser-provider-browserstack#master"
  1. This will update the package.json and will build the package directly from github.
$ cat package.json
...
 "testcafe-browser-provider-browserstack": "github:DevExpress/testcafe-browser-provider-browserstack#master"
...

Building the plugin locally

  1. Clone the browserstack provider repository
git clone https://github.com/DevExpress/testcafe-browser-provider-browserstack.git
  1. Install the dependencies
cd testcafe-browser-provider-browserstack
npm install
  1. Build the package, using gulp
./node_modules/.bin/gulp build
  1. Link the package globally
npm link
  1. This should link the package globally.

Running test using already running local binary

Spawn the BrowserStackLocal binary in a new window and pass a local-identifier to identify the tunnel connection. This is required by testcafe to identify the tunnel through which data has to be sent.

./BrowserStackLocal --key <access-key> --local-identifier <local-identifier-string> --verbose 3

Running testcafe session using already running local process

If we want to use the already running local binary for the tests, we need to pass an environment variable to set the identifier for testcafe. This can be done using export BROWSERSTACK_LOCAL_IDENTIFIER=<local-indentifier-string>;.

Sample command using this environment variable to start an automate testcafe session:

export  BROWSERSTACK_BUILD_ID='<build-name>'; export BROWSERSTACK_USE_AUTOMATE=1; export BROWSERSTACK_LOCAL_IDENTIFIER='<local-identifier-string>'; testcafe 'browserstack:chrome' simple_fixture.testcafe.js

Using the locally built package as your dependecy

To use the locally built testcafe plugin in your code. We have to first link the package globally and install that package from filesystem into the respective projects package.json. This can be easily done by using npm install <path-to-testcafe-browser-provider-browserstack-foler>.

This will link the global package to your local dependencies.

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