{"id":13057,"library":"danger-plugin-no-test-shortcuts","title":"Danger Plugin: No Test Shortcuts","description":"danger-plugin-no-test-shortcuts is a Danger JS plugin designed to prevent pull requests from being merged if they introduce test shortcuts like `.only()` or `.skip()` into test files. These shortcuts, while useful for local development, can lead to incomplete test runs on CI/CD pipelines. The plugin enforces proper test suite execution by failing the Danger build when such patterns are detected. The current stable version is 2.0.0, released in 2017. The project appears to have an infrequent release cadence, with the last major update several years ago. Its primary differentiation is its tight integration with Danger JS workflows, acting as a gatekeeper for code quality specifically around test suite integrity, allowing for custom file predicates and skip/only patterns.","status":"abandoned","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/macklinu/danger-plugin-no-test-shortcuts","tags":["javascript","danger","danger-plugin","typescript"],"install":[{"cmd":"npm install danger-plugin-no-test-shortcuts","lang":"bash","label":"npm"},{"cmd":"yarn add danger-plugin-no-test-shortcuts","lang":"bash","label":"yarn"},{"cmd":"pnpm add danger-plugin-no-test-shortcuts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Danger plugin and requires Danger JS to run.","package":"danger","optional":false}],"imports":[{"note":"The plugin exports a default function, not a named export. Ensure to use the default import syntax. TypeScript types are included.","wrong":"import { noTestShortcuts } from 'danger-plugin-no-test-shortcuts'","symbol":"noTestShortcuts","correct":"import noTestShortcuts from 'danger-plugin-no-test-shortcuts'"},{"note":"For CommonJS environments, use `require` to import the default export directly.","wrong":"const { noTestShortcuts } = require('danger-plugin-no-test-shortcuts')","symbol":"noTestShortcuts","correct":"const noTestShortcuts = require('danger-plugin-no-test-shortcuts')"}],"quickstart":{"code":"import noTestShortcuts from 'danger-plugin-no-test-shortcuts';\n\n// Configure the plugin to check for test shortcuts in files ending with '.test.ts' or '.spec.js'\n// and explicitly fail the build if any `test.skip()` calls are found.\nnoTestShortcuts({\n  testFilePredicate: (filePath) =>\n    filePath.endsWith('.test.ts') || filePath.endsWith('.spec.js'),\n  skippedTests: 'fail',\n  // Optionally add custom patterns if your test framework uses unique skip/only syntax\n  // patterns: {\n  //   only: ['myOnlyTest'],\n  //   skip: ['mySkipTest']\n  // }\n});\n\n// Example of other Danger usage (optional, just for context)\nif (danger.github.pr.body.length < 10) {\n  warn('Please provide a more descriptive PR body.');\n}\n\n// To run this, you would typically execute `danger pr --dangerfile dangerfile.js`\n// in your CI/CD pipeline.","lang":"typescript","description":"This quickstart demonstrates how to import and configure `danger-plugin-no-test-shortcuts` within a Dangerfile to enforce a policy against `.only` and `.skip` in test files, with custom file matching and failure on skipped tests."},"warnings":[{"fix":"Ensure your `noTestShortcuts` call includes a `testFilePredicate` function, e.g., `testFilePredicate: (filePath) => filePath.endsWith('.test.js')`.","message":"As of v2.0.0, the `testFilePredicate` option transitioned from optional to required. If you upgrade to v2.x, you must supply this predicate or Danger will fail.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Configure `noTestShortcuts({ skippedTests: 'fail' })` or `noTestShortcuts({ skippedTests: 'warn' })` to enable checks for skipped tests.","message":"The default behavior for `skippedTests` is 'ignore'. If you want Danger to warn or fail on `test.skip()` calls, you must explicitly set the `skippedTests` option to 'warn' or 'fail'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Carefully define your `testFilePredicate` to accurately match your project's test file naming conventions and paths. Consider using `danger.git.modified_files` or `danger.git.created_files` in conjunction for more precise filtering.","message":"Incorrectly configured `testFilePredicate` can lead to false negatives (missing shortcuts in actual test files) or false positives (checking non-test files).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Thoroughly test the plugin with your current Danger JS and Node.js versions. Monitor for potential incompatibilities or lack of support for new test shortcut patterns. Consider contributing to the project or migrating to a more actively maintained alternative if issues arise.","message":"The package appears to be unmaintained, with the last release in 2017. While it might still function, it may not be compatible with newer versions of Node.js, Danger JS, or address modern testing framework syntax for shortcuts. Use with caution or consider forking/updating.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Update your `Dangerfile` to include the `testFilePredicate` option: `noTestShortcuts({ testFilePredicate: (filePath) => filePath.endsWith('.test.js') })`.","cause":"`testFilePredicate` was not provided in the options object to `noTestShortcuts` after upgrading to v2.0.0 or later.","error":"TypeError: Cannot read properties of undefined (reading 'testFilePredicate')"},{"fix":"If your `Dangerfile` is a CommonJS module, use `const noTestShortcuts = require('danger-plugin-no-test-shortcuts')`. If it's an ESM module, ensure your environment supports it and your `package.json` has `\"type\": \"module\"`.","cause":"Attempting to use `import` syntax in a Dangerfile that is executed as a CommonJS module, or vice-versa.","error":"SyntaxError: Unexpected token 'export' (or similar ESM error in CJS context)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}