Giter Club home page Giter Club logo

stop-only's Introduction

stop-only

Detects '.only' left in the code accidentally. Works with "describe", "context" and "it".

NPM

Build status semantic-release renovate-app badge

Install

Requires Node, but this is a shell script.

npm install --save-dev stop-only

Use

basic

Assuming the tests are in the folder "specs", I recommend create an NPM run script. Use --folder or -f to pass the folder(s) to search.

{
  "scripts": {
    "stop-only": "stop-only --folder specs --folder bin"
  }
}

Exits with 1 if there is ".only" somewhere in the files inside "specs" folder or inside "bin" folder.

warn

If you just want to warn on found .only, use stop-only --warn --folder <folder path> syntax. Alias -w.

exclude folders

If you need to exclude certain folders, use --skip or -s option.

{
  "scripts": {
    "stop-only": "stop-only --folder specs --skip node_modules"
  }
}

exclude files

You can exclude files by name using --exclude or -e option.

{
  "scripts": {
    "stop-only": "stop-only --folder specs --exclude foo-spec.js"
  }
}

searching file

You can search a single file using --file argument

stop-only --file tests/spec.js

Or just warn

stop-only --warn --file tests/spec.js

any text

You can search for any text (and not just .only) by passing the parameter --text. For example, to find stray ".pause()" commands left in your specs, you can do

stop-only --folder specs --text '.pause()'

Pre-commit or pre-push hook

If using pre-git to configure Git hooks, run this tool as a command

{
  "config": {
    "pre-git": {
      "pre-push": ["npm run stop-only"]
    }
  }
}

See package.json (note here we have just local script name).

tip you can warn on commit hook, while fail in pre-push hook.

Check staged files only

You can catch left-over .only in staged files only (and not in the entire folder). For example by using husky and lint-staged and --file argument.

{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.js": "stop-only --file"
  }
}

lint-staged in this case will call stop-only --file <staged filename> for each staged file. You can see all commands by running Git commit command with DEBUG=lint-staged* environment variable.

Commas

You can pass multiple folder names as separate arguments or comma-separated. These are equivalent

stop-only --folder foo --folder bar --skip src --skip source
stop-only -f foo -f bar -s src -s source
stop-only -f foo,bar -s src,source

Debugging

You can see additional diagnostic output from this command by running with environment variable DEBUG=stop-only

CI

On CI run the tool after install, for example see .travis.yml, (note here we have just local script name).

- npm run stop-only

Small print

Author: Gleb Bahmutov <[email protected]> © 2017

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2017 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

stop-only's People

Contributors

bahmutov avatar flotwig avatar minh-nguyen-97 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

stop-only's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:babel6). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency deprecation warning: travis-deploy-once (npm)

On registry https://registry.npmjs.org/, the "latest" version (v5.0.11) of dependency travis-deploy-once has the following deprecation notice:

We recommend to use Travis Build Stages instead

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): package.json

If you don't care about this, you can close this issue and not be warned about travis-deploy-once's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

Customize words that prepend the ".only" statement

Right now I'm using this check on all my workspaces containing Cypress, but I'd like to also use it when doing unit testing with different libraries that don't use the same conventions as cypress does.

Right now I'm making this possible by renaming some of my testing functions to use the "describe" and/or "it". It's not the most straightforward way to do it seeing that I have to implementing in all of out test cases (a lot of them!). It would be great if you could define a set of words to check for the ".only" apart from the predefined ones.

If there is a way to do it and I haven't found it please do tell me!

Also thanks for this lifesaver of a check.

Need to handle tests only

Instead of searching for ".only" need to search for tests / suites. Currently finds these wrong text matches

packages/server/test/e2e/4_window_open_spec.coffee:8:  ## .only causing test failures
packages/server/test/spec_helper.coffee:34:  backup = global[prop].only
packages/server/test/spec_helper.coffee:36:  global[prop].only = ->

probably better would be to search for "it.only", "context.only" and "describe.only"

Dependency deprecation warning: nsp (npm)

On registry https://registry.npmjs.org, the "latest" version (v3.2.1) of dependency nsp has the following deprecation notice:

The Node Security Platform service is shutting down 9/30 - https://blog.npmjs.org/post/175511531085/the-node-security-platform-service-is-shutting

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): package.json

If you don't care about this, you can close this issue and not be warned about nsp's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v3
  • bahmutov/npm-install v1
  • cycjimmy/semantic-release-action v3
  • ubuntu 20.04
npm
package.json
  • debug 4.3.4
  • execa 0.11.0
  • minimist 1.2.8
  • ban-sensitive-files 1.10.1
  • dependency-check 3.4.1
  • deps-ok 1.4.1
  • dont-crack 1.2.1
  • execa-wrap 1.4.0
  • git-issues 1.3.1
  • lazy-ass 1.6.0
  • license-checker 25.0.1
  • mocha 10.4.0
  • pre-git 3.17.1
  • prettier-standard 11.0.0
  • semantic-release 17.4.7
  • standard 14.3.4
  • node >=6

  • Check this box to trigger a request for Renovate to run again on this repository

Allow passing more arguments

for example for skipping folders in the search folder

for example searching "src" folder but exclude "src/node_modules"

--exclude-dir=node_modules

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.