diff options
Diffstat (limited to 'tests/runner/browserstack/local.js')
-rw-r--r-- | tests/runner/browserstack/local.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/runner/browserstack/local.js b/tests/runner/browserstack/local.js new file mode 100644 index 000000000..c84cf155c --- /dev/null +++ b/tests/runner/browserstack/local.js @@ -0,0 +1,34 @@ +import browserstackLocal from "browserstack-local"; + +export async function localTunnel( localIdentifier, opts = {} ) { + const tunnel = new browserstackLocal.Local(); + + return new Promise( ( resolve, reject ) => { + + // https://www.browserstack.com/docs/local-testing/binary-params + tunnel.start( + { + "enable-logging-for-api": "", + localIdentifier, + ...opts + }, + async( error ) => { + if ( error || !tunnel.isRunning() ) { + return reject( error ); + } + resolve( { + stop: function stopTunnel() { + return new Promise( ( resolve, reject ) => { + tunnel.stop( ( error ) => { + if ( error ) { + return reject( error ); + } + resolve(); + } ); + } ); + } + } ); + } + ); + } ); +} |