每次保存更改时如何从 运行 Mocha/Chai/WebdriverIO 测试中停止 Selenium 独立服务器?

How to Stop Selenium Standalone Server from Running Mocha/Chai/WebdriverIO Tests Every Time I Save a Change?

我目前正在使用带有 Mocha、Chai 和 WebdriverIO 的测试框架。就目前而言,每当我保存对规范文件的更改时,Selenium 独立服务器 运行 就是完整的测试套件。当我在终端中输入命令时,我想禁用它并且只 运行 测试套件。此命令目前有效,但由于测试也在 运行 自动保存,有时多个相同的测试 运行 同时发生,导致错误。

如何停止 Selenium 独立服务器自动 运行ning 测试?

更新:作为评论者的要求,这是我的package.json

{
  "name": "react-slingshot",
  "version": "5.0.0",
  "description": "Starter kit for creating apps with React and Redux",
  "main": "index.js",
  "engines": {
    "npm": ">=3"
  },
  "scripts": {
    "preinstall": "node tools/nodeVersionCheck.js",
    "setup": "node tools/setup/setupMessage.js && npm install && node tools/setup/setup.js",
    "start-message": "babel-node tools/startMessage.js",
    "prestart": "npm-run-all --parallel start-message remove-dist",
    "start": "npm-run-all --parallel test:watch open:src lint:watch",
    "open:src": "babel-node tools/srcServer.js",
    "open:dist": "babel-node tools/distServer.js",
    "lint": "esw webpack.config.* src tools --color",
    "lint:watch": "npm run lint -- --watch",
    "clean-dist": "npm run remove-dist && mkdir dist",
    "remove-dist": "rimraf ./dist",
    "prebuild": "npm run clean-dist && npm run lint && npm run test",
    "build": "babel-node tools/build.js && npm run open:dist",
    "build-prod": "babel-node tools/build.js",
    "test": "mocha tools/testSetup.js \"./{,!(node_modules)/**/}*.spec.js\" --reporter progress",
    "test:cover": "babel-node node_modules/isparta/bin/isparta cover --root src --report html node_modules/mocha/bin/_mocha -- --require ./tools/testSetup.js \"./{,!(node_modules)/**/}*.spec.js\" --reporter progress",
    "test:cover:travis": "babel-node node_modules/isparta/bin/isparta cover --root src --report lcovonly _mocha -- --require ./tools/testSetup.js \"./{,!(node_modules)/**/}*.spec.js\" && cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js",
    "test:watch": "npm run test -- --watch",
    "open:cover": "npm run test:cover && open coverage/index.html",
    "analyze-bundle": "babel-node ./tools/analyzeBundle.js",
    "scp-upload": "node tools/deployToRemote",
    "deploy": "babel-node tools/build.js && npm run scp-upload"
  },
  "author": "Cory House",
  "license": "MIT",
  "dependencies": {
    "axios": "0.15.2",
    "babel-plugin-react-css-modules": "3.1.0",
    "bootstrap-sass": "3.3.7",
    "dotenv": "4.0.0",
    "font-awesome": "4.7.0",
    "j-toker": "0.0.10-beta3",
    "jquery": "3.1.1",
    "less": "2.7.1",
    "lodash": "4.17.2",
    "moment": "2.17.1",
    "object-assign": "4.1.0",
    "pingpp-js": "2.1.5",
    "postcss-strip-inline-comments": "0.1.5",
    "qrcode.react": "0.6.1",
    "react": "15.3.2",
    "react-addons-css-transition-group": "15.4.1",
    "react-bootstrap": "0.30.8",
    "react-bootstrap-button-loader": "1.0.8",
    "react-bootstrap-date-picker": "5.0.1",
    "react-burger-menu": "1.10.14",
    "react-circular-progressbar": "0.1.3",
    "react-country-region-selector": "1.0.4",
    "react-document-meta": "2.1.1",
    "react-dom": "15.3.2",
    "react-dropzone": "3.13.1",
    "react-ga": "2.1.2",
    "react-gravatar": "2.6.1",
    "react-lazyload": "2.2.7",
    "react-masonry-component": "5.0.3",
    "react-pager": "1.2.1",
    "react-progress-button": "5.0.4",
    "react-redux": "4.4.5",
    "react-responsive": "1.3.0",
    "react-router": "3.0.5",
    "react-router-bootstrap": "0.23.1",
    "react-router-redux": "4.0.6",
    "react-scroll": "1.5.2",
    "react-share": "1.12.1",
    "react-sidebar": "2.3.0",
    "react-slick": "0.15.0",
    "react-svg": "2.1.19",
    "redux": "3.6.0",
    "redux-form": "6.6.3",
    "redux-promise": "0.5.3",
    "redux-thunk": "2.1.0",
    "redux-ui": "0.0.15",
    "scp2": "0.5.0",
    "slick-carousel": "1.6.0",
    "svg-injector": "1.1.3",
    "universal-cookie": "2.0.8"
  },
  "devDependencies": {
    "assets-webpack-plugin": "3.5.1",
    "autoprefixer": "6.5.1",
    "babel-cli": "6.16.0",
    "babel-core": "6.17.0",
    "babel-eslint": "7.0.0",
    "babel-loader": "7.1.1",
    "babel-plugin-lodash": "3.2.11",
    "babel-plugin-react-display-name": "2.0.0",
    "babel-plugin-syntax-dynamic-import": "6.18.0",
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-plugin-transform-react-constant-elements": "6.9.1",
    "babel-plugin-transform-react-remove-prop-types": "0.2.10",
    "babel-polyfill": "6.23.0",
    "babel-preset-es2015": "6.24.1",
    "babel-preset-latest": "6.16.0",
    "babel-preset-react": "6.16.0",
    "babel-preset-react-hmre": "1.1.1",
    "babel-preset-stage-0": "6.24.1",
    "babel-preset-stage-1": "6.16.0",
    "babel-register": "6.16.3",
    "bootstrap": "3.3.7",
    "browser-sync": "2.17.5",
    "chai": "3.5.0",
    "chalk": "1.1.3",
    "compression-webpack-plugin": "0.3.2",
    "connect-history-api-fallback": "1.3.0",
    "coveralls": "2.11.14",
    "cross-env": "3.1.3",
    "css-loader": "0.28.4",
    "enzyme": "2.5.1",
    "eslint": "3.8.1",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1",
    "eslint-watch": "2.1.14",
    "extract-text-webpack-plugin": "3.0.0",
    "file-loader": "0.9.0",
    "html-webpack-plugin": "2.24.0",
    "imagemin-webpack-plugin": "1.4.4",
    "isparta": "4.0.0",
    "istanbul": "0.4.4",
    "json-loader": "0.5.4",
    "mocha": "3.1.2",
    "mockdate": "1.0.4",
    "node-sass": "3.10.1",
    "npm-run-all": "3.1.1",
    "open": "0.0.5",
    "postcss-cssnext": "3.0.2",
    "postcss-import": "10.0.0",
    "postcss-loader": "2.0.6",
    "postcss-scss": "1.0.2",
    "postcss-strip-inline-comments": "0.1.5",
    "postcss-url": "7.1.0",
    "precss": "2.0.0",
    "prompt": "1.0.0",
    "react-addons-test-utils": "15.3.2",
    "react-truncate": "2.1.0",
    "redux-devtools": "3.3.1",
    "redux-immutable-state-invariant": "1.2.4",
    "replace": "0.3.0",
    "resolve-url-loader": "1.6.0",
    "rimraf": "2.5.4",
    "s3-deploy": "0.7.3",
    "sass-loader": "4.0.2",
    "sinon": "1.17.6",
    "sinon-chai": "2.8.0",
    "style-loader": "0.13.1",
    "svg-url-loader": "2.1.1",
    "url-loader": "0.5.7",
    "wdio-mocha-framework": "0.5.11",
    "webdriverio": "4.8.0",
    "webpack": "3.5.5",
    "webpack-bundle-analyzer": "1.5.3",
    "webpack-dev-middleware": "1.8.4",
    "webpack-hot-middleware": "2.13.0",
    "webpack-md5-hash": "0.0.5"
  },
  "keywords": [
    "react",
    "reactjs",
    "react-router",
    "hot",
    "reload",
    "hmr",
    "live",
    "edit",
    "webpack",
    "redux",
    "flux",
    "boilerplate",
    "starter"
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/coryhouse/react-slingshot"
  }
}

更新 2: ps aux | grep npm 的输出:

cxk280            3750   0.0  0.9  3102016  37076 s003  S+    8:31PM   0:01.01 npm   
cxk280            3716   0.0  0.7  3096668  30752 s003  S+    8:31PM   0:01.14 node /Users/cxk280/code/my_directory/node_modules/.bin/nodemon --exec npm run babel-node
cxk280            3715   0.0  0.6  3102016  23348 s003  S+    8:31PM   0:00.92 npm  
cxk280            3383   0.0  0.6  3102016  23240 s001  S+    8:30PM   0:00.97 npm     
cxk280            3382   0.0  0.5  3102016  22540 s001  S+    8:30PM   0:00.97 npm     
cxk280            3379   0.0  0.5  3102016  22536 s001  S+    8:30PM   0:01.00 npm   
cxk280            3378   0.0  0.6  3102016  23236 s001  S+    8:30PM   0:01.00 npm   
cxk280            3377   0.0  0.6  3102056  23236 s001  S+    8:30PM   0:01.01 npm   
cxk280            3375   0.0  0.4  3081244  14712 s001  S+    8:30PM   0:00.66 node /Users/cxk280/code/my_directory/node_modules/.bin/npm-run-all --parallel test:watch open:src lint:watch
cxk280            3122   0.0  0.6  3102528  23244 s001  S+    8:30PM   0:00.76 npm  
cxk280            4520   0.0  0.0  2423384    232 s006  R+    8:32PM   0:00.00 grep npm

npm start为运行时,它运行执行以下命令:

npm-run-all --parallel test:watch open:src lint:watch

test:watch 可能会触发您的测试套件再次 运行。

如果你想避免这种情况,只需 运行 npm run open:src 启动你的服务器,然后 npm test 到 运行 你的测试。