Registry / testing / danger-plugin-no-test-shortcuts

danger-plugin-no-test-shortcuts

JSON →
library2.0.0jsnpmunverified

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-shortcuts
INSTALL
IMPORT
SIG · DANGER-PLUGIN-NO-T
D
danger-plugin-no-test-shortcuts
testingjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

noTestShortcuts
import noTestShortcuts from 'danger-plugin-no-test-shortcuts'
import { noTestShortcuts } from 'danger-plugin-no-test-shortcuts'
The plugin exports a default function, not a named export. Ensure to use the default import syntax. TypeScript types are included.
noTestShortcuts
const noTestShortcuts = require('danger-plugin-no-test-shortcuts')
const { noTestShortcuts } = require('danger-plugin-no-test-shortcuts')
For CommonJS environments, use `require` to import the default export directly.

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.

import noTestShortcuts from 'danger-plugin-no-test-shortcuts'; // Configure the plugin to check for test shortcuts in files ending with '.test.ts' or '.spec.js' // and explicitly fail the build if any `test.skip()` calls are found. noTestShortcuts({ testFilePredicate: (filePath) => filePath.endsWith('.test.ts') || filePath.endsWith('.spec.js'), skippedTests: 'fail', // Optionally add custom patterns if your test framework uses unique skip/only syntax // patterns: { // only: ['myOnlyTest'], // skip: ['mySkipTest'] // } }); // Example of other Danger usage (optional, just for context) if (danger.github.pr.body.length < 10) { warn('Please provide a more descriptive PR body.'); } // To run this, you would typically execute `danger pr --dangerfile dangerfile.js` // in your CI/CD pipeline.
Debug
Known issues
breakingAs 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.
fix
Ensure your `noTestShortcuts` call includes a `testFilePredicate` function, e.g., `testFilePredicate: (filePath) => filePath.endsWith('.test.js')`.
affects: >=2.0.0
gotchaThe 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'.
fix
Configure `noTestShortcuts({ skippedTests: 'fail' })` or `noTestShortcuts({ skippedTests: 'warn' })` to enable checks for skipped tests.
affects: >=1.0.0
gotchaIncorrectly configured `testFilePredicate` can lead to false negatives (missing shortcuts in actual test files) or false positives (checking non-test files).
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.
affects: >=1.0.0
deprecatedThe 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'testFilePredicate')
`testFilePredicate` was not provided in the options object to `noTestShortcuts` after upgrading to v2.0.0 or later.
fix
Update your `Dangerfile` to include the `testFilePredicate` option: `noTestShortcuts({ testFilePredicate: (filePath) => filePath.endsWith('.test.js') })`.
SyntaxError: Unexpected token 'export' (or similar ESM error in CJS context)
Attempting to use `import` syntax in a Dangerfile that is executed as a CommonJS module, or vice-versa.
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"`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
dangerrequiredThis is a Danger plugin and requires Danger JS to run.
Agent activity
10 hits · last 30 days
node
10
Resources
danger-plugin-no-test-shortcuts — npm install danger-plugin-no-test-shortcuts · libregistry