简体   繁体   English

每次保存更改时,如何停止Selenium Standalone Server运行Mocha / Chai / WebdriverIO测试?

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

I am currently using a testing framework with Mocha, Chai, and WebdriverIO. 我目前正在使用Mocha,Chai和WebdriverIO的测试框架。 As it stands, the Selenium Standalone Server runs the full test suite whenever I save a change to the spec file. 就目前而言,只要我将更改保存到规范文件中,Selenium Standalone Server就会运行完整的测试套件。 I want to disable this and only run the test suite when I enter the command to do so in the terminal. 我想禁用此功能,并且仅当在终端中输入执行此命令的命令时才运行测试套件。 This command currently works, but because the tests are also being run automatically on save, sometimes multiple identical tests run concurrently, causing errors. 该命令当前有效,但是由于测试也会在保存时自动运行,因此有时会同时运行多个相同的测试,从而导致错误。

How do I stop the Selenium Standalone Server from auto-running tests? 如何停止Selenium Standalone Server的自动运行测试?

Update: As a commenter requested, here is my package.json : 更新:根据评论者的要求,这是我的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"
  }
}

Update 2: The output of ps aux | grep npm 更新2: ps aux | grep npm的输出ps aux | grep npm ps aux | grep npm : 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

When npm start is run, it runs the following command: npm start ,它将运行以下命令:

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

The test:watch is what is likely triggering your test suite to run again. test:watch可能触发您的测试套件再次运行。

If you want to avoid that, just run npm run open:src to start your server, then npm test to run your test. 如果要避免这种情况,只需运行npm run open:src来启动服务器,然后npm test来运行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在独立/容器化服务器上​​运行Selenium测试 - How to run Selenium tests with a standalone / containerized server 如何通过 webdriverio wdio 文件更改 selenium-standalone 端口号? - How to change selenium-standalone port number via webdriverio wdio file? Python停止Selenium独立服务器 - python stop selenium standalone server Selenium Webdriver测试在执行一段时间后停止运行 - Selenium webdriver tests stop running after some time of execution 带有 Mocha/Chai 的 Selenium - 如何返回 false 是 DOM 中不存在的项目 - Selenium with Mocha/Chai - How to return false is item does not exist in DOM WebdriverIO测试不会针对dockerized Selenium服务器相应运行 - WebdriverIO tests don't run accordingly against dockerized Selenium server 如果Selenium服务器未运行,如何跳过PHPUnit中的测试? - How to skip tests in PHPUnit if Selenium server is not running? 在selenium server standalone上运行从selenium ide生成的java-exported测试 - Run java-exported tests generated from selenium ide on selenium server standalone 在webdriver.quit()之后如何停止运行硒测试? - How to stop running selenium tests AFTER webdriver.quit()? 硒摩卡测试 - Selenium mocha Tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM