Skip to content

Commit e31e0da

Browse files
committed
3.5.0
1 parent 6512110 commit e31e0da

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

docs/recipes.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,36 @@ Example below shows use of npm `pre` and `post` scripts in `package.json` to sta
2828

2929
```
3030

31+
However, if the npm `start` command exits with an error, the `poststart` script is never executed, and the BrowserStackLocal binary is left running on your system. You can cleanup all binaries by running `browserstack-local stop`.
32+
33+
A better option is to use `browserstack run-with -- <your-command>`.
34+
35+
This will:
36+
- Start the local binary
37+
- Set `BROWSERSTACK_LOCAL_IDENTIFIER` environment variable for `<your-command>`
38+
- Run `<your-command>` _synchronously_ as a child process inheriting `std*`
39+
- Stop the local binary after `<your-command>` ends
40+
- Exit with the exit code of `<your-command>`
41+
42+
```json
43+
{
44+
"name": "your-package",
45+
"version": "1.0.0",
46+
"main": "index.js",
47+
"scripts": {
48+
// use %npm_package_name% to pass your package name as localIdentifier on Windows
49+
"test": "browserstack-local run-with $npm_package_name -- playwright test",
50+
},
51+
"devDependencies": {
52+
"browserstack-client": "latest"
53+
}
54+
}
55+
56+
```
57+
3158
Optionally, you may supply a `localIdentifier` that distinguishes your current project from other local projects being tested on BrowserStack.
3259

33-
`browserstack-local (start|stop) [local-identifier]`
60+
`browserstack-local (start|stop|run-with) [local-identifier]`
3461

3562
> Calling `browserstack-local stop` without a local-identifier will terminate all locally running instances of the binary that have previously been started by `browserstack-local start`.
3663

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "browserstack-client",
3-
"version": "3.4.0",
3+
"version": "3.5.0",
44
"description": "BrowserStack APIs client library for node.js",
55
"type": "module",
66
"main": "./dist/browserstack-client.umd.cjs",

0 commit comments

Comments
 (0)