### Local Installation and Execution Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Installs the browserstack-runner package locally within a project and demonstrates how to execute the local binary. ```bash npm install browserstack-runner node_modules/.bin/browserstack-runner ``` -------------------------------- ### Install BrowserStack Runner Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Installs the browserstack-runner globally or as a dev-dependency using npm. ```bash npm install -g browserstack-runner ``` ```bash npm install --save-dev browserstack-runner ``` -------------------------------- ### QUnit Test with BrowserStack Runner Source: https://github.com/browserstack/browserstack-runner/blob/master/tests/behaviour/resources/qunit_sample.html This snippet shows a basic QUnit test case configured to run with the BrowserStack Runner. It includes setup for BrowserStack capabilities and assertions. ```javascript QUnit.module('BrowserStack Runner Integration', function() { QUnit.test('should run a simple test on BrowserStack', function(assert) { // BrowserStack Runner capabilities would be configured here // For example: // const capabilities = { // 'browser': 'Chrome', // 'browser_version': 'latest', // 'os': 'Windows', // 'os_version': '10', // 'project': 'BrowserStack Runner Example', // 'build': 'QUnit Build 1' // }; // Simulate an asynchronous operation or a simple assertion const done = assert.async(); setTimeout(function() { assert.ok(true, 'Test passed successfully!'); done(); }, 100); }); }); ``` -------------------------------- ### Global Installation Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Installs the browserstack-runner package globally using npm, making the command-line interface available system-wide. ```bash npm -g install browserstack-runner ``` -------------------------------- ### BrowserStack Runner Configuration (`browserstack.json`) Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Example configuration file for browserstack-runner, specifying test paths, frameworks, browsers, and proxy settings. ```json { "username": "YOUR_BROWSERSTACK_USERNAME", "key": "YOUR_BROWSERSTACK_ACCESS_KEY", "test_path": [ "test/qunit.html", "test/jasmine.html" ], "test_framework": "qunit", "timeout": 300, "browsers": [ { "os": "Windows", "os_version": "10", "browser": "Chrome", "browser_version": "latest" }, { "os": "ios", "os_version": "13", "browser": "Mobile Safari", "device": "iPhone 11" } ], "proxy": { "host": "localhost", "port": 3128, "username": "foo", "password": "bar" } } ``` -------------------------------- ### Local Install for Testing Source: https://github.com/browserstack/browserstack-runner/blob/master/CONTRIBUTING.md Installs browserstack-runner directly from a local checkout path into another project for testing purposes. ```bash # in your project npm install /path/to/checkout/browserstack-runner ``` -------------------------------- ### Install Dependencies Source: https://github.com/browserstack/browserstack-runner/blob/master/CONTRIBUTING.md Installs the necessary dependencies for the browserstack-runner project using npm. ```bash npm install ``` -------------------------------- ### Browser Configuration for Desktop Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Example of a browser object within the 'browsers' array for specifying desktop browser test configurations. ```json { "browser": "ie", "browser_version": "10.0", "os": "Windows", "os_version": "8", "cli_key": 1 } ``` -------------------------------- ### Browser Configuration for Mobile Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Example of browser objects within the 'browsers' array for specifying mobile device test configurations. ```json [ { "os": "ios", "os_version": "8.3", "device": "iPhone 6 Plus", "cli_key": 1 }, { "os": "android", "os_version": "4.0", "device": "Google Nexus", "cli_key": 2 } ] ``` -------------------------------- ### Proxy Configuration for Local Tunnel Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Example of how to configure proxy settings within browserstack.json for establishing a local tunnel. ```json { "proxy": { "host": "localhost", "port": 3128, "username": "foo", "password": "bar" } } ``` -------------------------------- ### Configuring npm User Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Provides a solution for EACCES errors related to BrowserStackLocal by configuring npm to use a user with sufficient permissions for global installations. ```bash npm -g config set user [user] ``` -------------------------------- ### Generate browserstack-util.js with Webpack Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Updates the browserstack-util.js file, which contains browser-compatible code for Node's util.inspect, used for serializing console.log data. Requires global webpack installation. ```bash npm install -g webpack npm run update-util ``` -------------------------------- ### Configure npm User for EACCES Error Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Resolves EACCES errors related to BrowserStackLocal by configuring npm to install modules with a specified user instead of the default 'nobody'. ```bash npm -g config set user [user] ``` -------------------------------- ### Sample CLI Usage Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Demonstrates a sample command for running browserstack-runner with multiple CLI options, including specifying browsers, a custom path, a pid file, and verbose logging. ```bash browserstack_runner --browsers 1 2 3 --path 'path/to/test/runner' --pid 'path/to/pid/file' -v ``` -------------------------------- ### CLI Options Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Lists and explains the available command-line interface options for the browserstack-runner, including path, pid, verbose, and browsers. ```bash --path: Specify a custom test runner path. --pid: Set a custom pid file for BrowserStackLocal instances. --verbose or -v: Enable verbose logging. --browsers or -b: Run tests on a space-separated list of specified browsers. ``` -------------------------------- ### BrowserStack Runner Configuration File Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md A sample browserstack.json file demonstrating the structure and common parameters for configuring BrowserStack tests. ```json { "username": "", "key": "", "test_framework": "qunit|jasmine|jasmine2|mocha", "test_path": ["relative/path/to/test/page1", "relative/path/to/test/page2"], "test_server_port": "8899", "browsers": [ { "browser": "ie", "browser_version": "10.0", "device": null, "os": "Windows", "os_version": "8", "cli_key": 1 }, { "os": "android", "os_version": "4.0", "device": "Samsung Galaxy Nexus", "cli_key": 2 }, { "os": "ios", "os_version": "7.0", "device": "iPhone 5S", "cli_key": 3 } ] } ``` -------------------------------- ### Initialize BrowserStack Runner Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Command to initialize the browserstack.json configuration file. Allows specifying a custom preset and the path to test files. ```bash browserstack-runner init [preset] [path] ``` -------------------------------- ### Initialize BrowserStack Runner Configuration Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Command to generate a default `browserstack.json` file in the project's root directory. ```bash browserstack-runner init ``` -------------------------------- ### Running BrowserStack Runner Tests Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Commands to execute the test suites for the BrowserStack Runner. Includes commands for standard testing and a more comprehensive CI testing suite. ```bash npm test npm run test-ci ``` -------------------------------- ### Run BrowserStack Runner Tests Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Executes the test suite for BrowserStack Runner. Includes commands for standard tests and a more comprehensive CI test suite for compatibility. ```bash npm test npm run test-ci ``` -------------------------------- ### Run Tests with BrowserStack Runner Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Executes the configured tests on BrowserStack. Add `--verbose` for detailed output. ```bash browserstack-runner ``` ```bash browserstack-runner --verbose ``` -------------------------------- ### Run Tests Source: https://github.com/browserstack/browserstack-runner/blob/master/CONTRIBUTING.md Executes the project's unit tests and linting tools using npm. ```bash npm test ``` -------------------------------- ### Compact Browser Configuration Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Demonstrates using shorthand notation for specifying browser versions (current, previous, specific) in the 'browsers' array. ```json { "browsers": [ "chrome_previous", "chrome_latest", "firefox_previous", "firefox_latest", "ie_6", "ie_11", "opera_12_1", "safari_5_1", { "browser": "ie", "browser_version": "10.0", "device": null, "os": "Windows", "os_version": "8", "cli_key": 1 } ] } ``` -------------------------------- ### Usage as a Module Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Shows how to use the browserstack-runner as a Node.js module, including requiring the module, loading configuration, and running tests with a callback for results. ```javascript var browserstackRunner = require("browserstack-runner"); var config = require("./browserstack.json"); browserstackRunner.run(config, function(error, report) { if (error) { console.log("Error:" + error); return; } console.log(JSON.stringify(report, null, 2)); console.log("Test Finished"); }); ``` -------------------------------- ### BrowserStack API - Create Workers Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner This documentation describes how to create API workers for running tests on BrowserStack. It outlines the settings and callback parameters involved in the process. ```javascript client.createWorkers(settings, callback) - settings: An object containing configuration for the workers. - browsers: An array of browser configurations. - os: Operating system (e.g., "Windows", "ios"). - os_version: OS version (e.g., "10", "7.0"). - browser: Browser name (e.g., "Chrome", "Mobile Safari"). - browser_version: Browser version (e.g., "latest", "10.0"). - device: Device name for mobile emulators (optional). - callback: A function to handle the response from the API. - error: An error object if the request failed. - workers: An array of worker objects representing the launched browsers. ``` -------------------------------- ### Link Locally for Testing Source: https://github.com/browserstack/browserstack-runner/blob/master/CONTRIBUTING.md Allows testing local changes of browserstack-runner within another project by creating a symbolic link. ```bash # in your browserstack-runner checkout npm link # in your project npm link browserstack-runner ``` -------------------------------- ### Environment Variables for BrowserStack Runner Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Configuration options for BrowserStack Runner using environment variables. These variables help manage user credentials, tunnel IDs, and file paths, avoiding duplication across configuration files. ```bash export BROWSERSTACK_USERNAME="your_username" export BROWSERSTACK_KEY="your_access_key" export TUNNEL_ID="unique_tunnel_identifier" export BROWSERSTACK_JSON="/path/to/browserstack.json" export BROWSERSTACK_LOCAL_BINARY_PATH="/path/to/BrowserStackLocal" ``` -------------------------------- ### Resolving Travis CI Timeout Issues Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Strategies to prevent build timeouts on Travis CI when the BrowserStack Runner takes longer than 10 minutes to execute tests. Recommends using `travis_wait` for extended build times. ```bash # Option 1: Periodic console logging (less recommended) # Run a script that logs output every 1-2 minutes. # Option 2: Using travis_wait (recommended) travis_wait 20 npm run browserstack-runner ``` -------------------------------- ### Run BrowserStack Local in Debug Mode Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Enables debug mode for BrowserStack Local by setting the LOG_LEVEL environment variable to 'trace' and running the browserstack-runner with the --verbose flag. ```bash LOG_LEVEL=trace browserstack-runner --verbose ``` -------------------------------- ### BrowserStack Runner Report Structure Source: https://github.com/browserstack/browserstack-runner/blob/master/README.md Details the structure of the report object returned by the browserstackRunner.run function, including browser information, test results, and suite details. ```json [ { "browser": "Windows 7, Firefox 47.0", "tests": [ { "name": "isOdd()", "suiteName": "Odd Tests", "fullName": ["Odd Tests", "isOdd()"], "status": "passed", "runtime": 2, "errors": [], "assertions": [ { "passed": true, "actual": true, "expected": true, "message": "One is an odd number" } ] } ], "suites": { "fullName": [], "childSuites": [ { "name": "Odd Tests", "fullName": ["Odd Tests"], "childSuites": [], "tests": [ { "name": "isOdd()", "suiteName": "Odd Tests", "fullName": ["Odd Tests", "isOdd()"], "status": "passed", "runtime": 2, "errors": [], "assertions": [ { "passed": true, "actual": true, "expected": true, "message": "One is an odd number" } ] } ], "status": "passed", "testCounts": { "passed": 1, "failed": 0, "skipped": 0, "total": 1 }, "runtime": 2 } ], "tests": [], "status": "passed", "testCounts": { "passed": 1, "failed": 0, "skipped": 0, "total": 1 }, "runtime": 2 } } ] ``` -------------------------------- ### Mocha Test Execution in Browser Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Ensures Mocha tests are executed after patch files are loaded by wrapping the `mocha.run()` call within `window.onload`. ```javascript window.onload = function () { mocha.run(); } ``` -------------------------------- ### Node util.inspect API Reference Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Provides a reference for Node.js's util.inspect function, which is used for serializing objects and inspecting their properties. The browserstack-util.js file provides a browser-compatible version of this functionality. ```APIDOC util.inspect(object[, options]) util.inspect(object[, showHidden[, depth[, color]]]) - object: The object to inspect. - options: An object that modifies the output. Can have the following properties: - showHidden: If true, the object's non-enumerable properties will be shown. - depth: The number of times to recurse while formatting the object to inspect. Default is 2. Returns the formatted string of the object. null for an infinite number of inspects. - color: If true, the output will be styled with ANSI color codes. Default is false. - customInspect: If false, the custom inspect method of child objects will be ignored. Default is true. - showProxy: If true, the special properties of Proxy objects will be shown. Default is false. - maxArrayLength: Specifies how many elements of the array should be displayed. Set to null to show all elements. Defaults to 100. - maxStringLength: Specifies how many characters of the string should be displayed. Set to null to show all characters. Defaults to 10000. - breakLength: Specifies the line length at which an object is split into multiple lines. If an object is longer than this length, a break will be inserted. - compact: If false, the output will be more spaced out. If true, the output will be more compact. - sorted: If true, the object properties will be sorted. Returns: The string representation of object. This may be useful for debugging. Example: const util = require('util'); const obj = { name: 'example', details: { version: 1, active: true } }; console.log(util.inspect(obj)); // Output: { name: 'example', details: { version: 1, active: true } } console.log(util.inspect(obj, { showHidden: true, depth: null })); // Output: { name: 'example', details: { version: 1, active: true } } ``` -------------------------------- ### Jasmine v1 Test Execution in Browser Source: https://github.com/browserstack/browserstack-runner/wiki/BrowserStack-Runner Ensures Jasmine v1 tests are executed after patch files are loaded by wrapping the `jasmine.getEnv().execute()` call within `window.onload`. ```javascript window.onload = function () { jasmine.getEnv().execute(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.