Gathering detailed insights and metrics for find-related-tests-js
Gathering detailed insights and metrics for find-related-tests-js
npm install find-related-tests-js
Typescript
Module System
Node Version
NPM Version
61.2
Supply Chain
91.9
Quality
71.4
Maintenance
50
Vulnerability
97.3
License
TypeScript (76.41%)
JavaScript (23.59%)
Total Downloads
3,846
Last Day
22
Last Week
23
Last Month
68
Last Year
339
2 Stars
14 Commits
1 Forks
2 Watching
9 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.3.0
Package Id
find-related-tests-js@1.3.0
Unpacked Size
148.51 kB
Size
57.35 kB
File Count
24
NPM Version
6.4.1
Node Version
10.15.3
Cumulative downloads
Total Downloads
Last day
0%
22
Compared to previous day
Last week
-46.5%
23
Compared to previous week
Last month
1,260%
68
Compared to previous month
Last year
-36.5%
339
Compared to previous year
Sometimes we need not run all unit tests in our project. This library will try to find the related files(i.e import files) of all files changed in current branch.
This library can be an alternate for jest findRelatedTests or jest changedSince with much more flexibility. Here consumers are responsible to map test file for each related source file.
npm install --save find-related-tests-js
Callbacks:
Accumulator:
accumulator.add(testFileName)
. The result will be unique so need to not worry about duplicates.// config.js
// mandatory parameters
function mapSourceToTestFiles(sourceFile, accumulator) {
if (sourceFile.indexOf('.test.js') >= 1) {
// Add if this is already a test file
accumulator.add(sourceFile)
return
}
if (sourceFile.indexOf('.js') >= 1) {
// Map multiple test files for single source file
accumulator.add(sourceFile.replace(/\.js/, '.test.js'));
accumulator.add(sourceFile.replace(/\.js/, '.snapshot.js'));
}
}
module.exports = {
entryPoint: '/react/sample/App.js',
searchDir: '/react/sample',
dependencyExcludeFilter: path => path.indexOf('node_modules') === -1, // Ignore node module from dep graph
// It is okay to add same file name in multiple callback
// result will be unique
sourceFileModifiedCb: mapSourceToTestFiles,
directDependencyModifiedCb: mapSourceToTestFiles,
transitiveDependencyModifiedCb: (sourceFile, accumulator) => {
// This will be called if any transitive dependency is modified
// A -> B -> C -> D
// C & D are transitive dependency for A
},
outputFile: '/react/temp.txt',
}
To findRelatedTests for staged files in Git
git diff --name-only | xargs printf -- "$PWD/%s\n" | find-related-tests-js --configPath $PWD/config.js --entryPoint $PWD/App.js --searchDir $PWD/src --outputFile temp.txt
To findRelatedTests for files committed but not pushed
git diff --name-only origin..head | xargs printf -- "$PWD/%s\n" | find-related-tests-js --configPath $PWD/config.js --entryPoint $PWD/App.js --searchDir $PWD/src --outputFile temp.txt
If you have not installed this package globally then use ./node_modules/find-related-tests-js/dist/cli.js
as executable.
Above command will find all related test files and write their path to configured output file. Run test candidates with required runner
yarn jest $(cat temp.txt)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
Found 0/14 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More