Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for Windows 10 (WSL) #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,23 @@ module.exports = (on, config) => {
on("file:preprocessor", watchApp(cucumber()));
};
```
### How to use on Windows

This example is to use browser-sync with cypress as described at https://www.26brains.com/2019/02/the-holy-grail-cypress-io-browser-sync-automatically-rerun-tests/

On Windows you need cross-env to set WAIT_FOR_MESSAGE variable. Also note double quotes in scripts (`WAIT_FOR_MESSAGE=\"Reloading Browsers...\"`)

```bash
npm install --save-dev cross-env npm-run-all
```

package.json:

```javascript
{
"serve": "browser-sync start -s src -w --no-open",
"cypress": "cypress open",
"serveWithCypress": "cross-env WAIT_FOR_MESSAGE=\"Reloading Browsers...\" cypressAppWatcher npm run serve",
"test": "npm-run-all --parallel serveWithCypress cypress"
}
```
6 changes: 3 additions & 3 deletions appWatcher.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env node
const { spawn } = require("child_process");
const { spawn } = require("cross-spawn");
const ipc = require("node-ipc");
ipc.config.silent = true;

let appProc;

function watchIt([command, ...rest]) {
appProc = spawn(myArgs[0], rest);
appProc = spawn(command, rest);

appProc.stdout.on("data", data => {
let stringifiedData = data.toString();
Expand All @@ -26,7 +26,7 @@ function watchIt([command, ...rest]) {
}

process.on("uncaughtException", exception => {
process.kill(appProc.pid);
process.exit(appProc.pid); // switched kill to exit, else invalid pid error on windows
throw new Error(exception);
});

Expand Down
84 changes: 72 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"@cypress/browserify-preprocessor": "^1.1.0",
"cross-spawn": "^7.0.1",
"node-ipc": "^9.1.1"
},
"keywords": [
Expand Down