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.
npm install danger-plugin-no-test-shortcutsVerified import paths — ran on the pinned version, not inferred.
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.
Ensure your `noTestShortcuts` call includes a `testFilePredicate` function, e.g., `testFilePredicate: (filePath) => filePath.endsWith('.test.js')`.Configure `noTestShortcuts({ skippedTests: 'fail' })` or `noTestShortcuts({ skippedTests: 'warn' })` to enable checks for skipped tests.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.
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.
Update your `Dangerfile` to include the `testFilePredicate` option: `noTestShortcuts({ testFilePredicate: (filePath) => filePath.endsWith('.test.js') })`.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"`.