@belym.a.2105/sauce-tunnel

中文文档
3.0.0发布于 2023/08/07MITCommonJS近 30 天下载 3277

A wrapper around the Sauce Labs tunnel jar

原始使用文档
文档目录21 节
  1. Usage
  2. Full Example
  3. CHANGELOG
  4. v1.1
  5. v2.0
  6. v2.0.1
  7. v2.0.2
  8. v2.0.3
  9. v2.0.4
  10. v2.0.5
  11. v2.0.6
  12. v2.1.0
  13. v2.1.1
  14. v2.2.0
  15. v2.2.1
  16. v2.2.2
  17. v2.2.3
  18. v2.2.4
  19. v2.3.0
  20. v2.4.0
  21. v2.5.0

#sauce-tunnel NPM version Build Status

A Node.js wrapper around the Saucelabs tunnel jar.

This code is extracted from grunt-saucelabs by axemclion, with the grunt-specific parts removed.

It was extracted into its own module to avoid duplication between grunt-saucelabs, grunt-mocha-webdriver, and any future Node module that may need it.

Usage

Before starting the tunnel, initialize it first

var tunnel = new SauceTunnel(SAUCE_USERNAME, SAUCE_ACCESS_KEY, tunnelIdentifier, tunneled, extraFlags);
  1. SAUCE_USERNAME and SAUCE_ACCESS_KEY are the username and the accesskey for saucelabs. They are usually set as environment variables (specially in continuous integration tools like travis )
  2. The tunnelIdentifier is a unique identifier for the tunnel. It is optional and is automatically generated when not specified. Note that the tunnel identifier may have to be passed in with the browsers object as a desired capability to enable traffic to use the tunnel. More details here
  3. The tunneled attribute is a boolean value to indicate if the tunnel is to be created or not. This value can be set to false to mock a tunnel creation if the site tested is publicly accessible. This value is optional and defaults to true.
  4. The extraFlags attribute is an array of options flags (see here). Example: ['--debug', '--direct-domains', 'www.google.com']. It is optional.

Once the tunnel is initialized, start it with the following command.

tunnel.start(function(status){
  // status === true indicates that the tunnel was successfully created.
});

The actual webdriver code to run the test cases can be added inside the callback function. Once the webdriver completes its task, you can shut down the tunnel using

tunnel.stop(function(){
  // Tunnel was stopped
});

Full Example

To get started easily, here is the code you can copy paste

var SauceTunnel = require('sauce-tunnel');
var tunnel = new SauceTunnel(process.env.SAUCE_USERNAME, process.env.SAUCE_ACCESS_KEY, 'tunnel', true/* ['--verbose'] */);
tunnel.start(function(status){
  if (status === false){
    throw new Error('Something went wrong with the tunnel');
  }
  /** var wd =  ... Work with the web driver**/
  // Once all webdriver work is done
  tunnel.stop(function(){
    // Tunnel destroyed
  });
});

CHANGELOG

v1.1

  • Remove all the logic surrounding tracking open tunnels, killing existing tunnels, and tunnel timeouts. (#3)

v2.0

  • Move to new release of Sauce connect (version 4).

v2.0.1

  • Fixing bug where sauce connect was not properly exiting

v2.0.2

  • Fixing issue with flaky tunnel creation recognition on Win

v2.0.3

  • Updating Sauce Tunnel 4 binaries (@saadtazi)

v2.0.4

  • Updating to Sauce Connect 4.1

v2.0.5

  • Switch to using chalk instead of duck punching String.

v2.0.6

  • Update to SC 4.2

v2.1.0

  • Update to SC 4.3

v2.1.1

  • Update to SC 4.3.5
  • Expose kill method for immediate kill of process

v2.2.0

  • Update binaries to SC 4.3.6
  • Make tunneled an optional param that defaults to true
  • Fix bug in delete tunnel

v2.2.1

  • Add 32bit binary for Linux

v2.2.2

  • Fix race condition from delete tunnel fix in 2.2.0

v2.2.3

  • Update SC binaries to 4.3.7
  • Update Chalk to 1.0

v2.2.4

  • Update SC binaries to 4.3.9

v2.3.0

  • Update SC binaries to 4.3.12

v2.4.0

  • Update SC binaries to 4.3.13
  • Update Node dependencies to latest

v2.5.0

  • Update SC binaries to 4.3.16
  • Update Node dependencies to latest

版本与发布记录

@belym.a.2105/sauce-tunnel 共发布 3 个版本,首次发布于 2018/07/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2023/08/073 年前
2.5.22021/01/115 年前
2.5.12018/07/128 年前

关于 @belym.a.2105/sauce-tunnel 的常见问题

@belym.a.2105/sauce-tunnel 是什么?

A wrapper around the Sauce Labs tunnel jar

如何安装 @belym.a.2105/sauce-tunnel?

在项目目录运行 npm install @belym.a.2105/sauce-tunnel,或使用 pnpm add / yarn add / bun add。

@belym.a.2105/sauce-tunnel 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/belym.a.2105__sauce-tunnel 是否存在。

@belym.a.2105/sauce-tunnel 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@belym.a.2105/sauce-tunnel 可以商用吗?

@belym.a.2105/sauce-tunnel 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@belym.a.2105/sauce-tunnel 的下载量有多少?

根据 npm 官方下载统计,@belym.a.2105/sauce-tunnel 在 2026/10/08 – 2026/11/06 这 30 天内被下载 3,277 次,日均约 109 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@belym.a.2105/sauce-tunnel 还在维护吗?

最新版本 3.0.0 发布于 2023/08/07(3 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/07/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。