Open mhdawson opened 2 years ago
Taking a look at what happens when npcheck
runs for jest
...
src/plugins/tests.js
's algorithm for checking for the presence of tests appears to be:
test
script (i.e. script containing the word test
) https://github.com/nodeshift/npcheck/blob/655de20ae73ae2882feba5fd0efdc797360c5525/src/plugins/tests.js#L12-L16test
directory (i.e. directory containing the word test
) https://github.com/nodeshift/npcheck/blob/655de20ae73ae2882feba5fd0efdc797360c5525/src/plugins/tests.js#L18-L33There appear to be issues in both of these checks.
For 1. the pkg
object is the result of npm show --json <package name>
https://github.com/nodeshift/npcheck/blob/655de20ae73ae2882feba5fd0efdc797360c5525/src/lib/npm.js#L6-L9. If I run npm show --json jest
then we can see no scripts
are returned (i.e. npm show
isn't the same as the repository's root package.json
file):
For 2. the algorithm checks trees
but isn't recursing so it will only detect directories containing the word test
in the root directory of the repository.
For 1. yeah there is no guarantee that the result will be the expected:
❯ npm show @openapitools/openapi-generator-cli scripts
{ postinstall: 'opencollective || exit 0' }
~/code took 2s
❯ npm show jest scripts
~/code
❯ npm show opossum scripts
{
prepare: 'husky install',
prebuild: 'npm run pretest',
build: './test/browser/generate-index.sh && npm run build:browser && npm run build:docs',
'build:browser': 'webpack --config=config/webpack.config.js',
'build:docs': 'npm run build:docs:html && npm run build:docs:markdown',
'build:docs:html': 'documentation build index.js -f html -o docs --config documentation.yml',
'build:docs:markdown': 'documentation build index.js -f md -o docs/opossum.md',
pretest: 'eslint --ignore-path .gitignore .',
test: 'nyc tape test/*.js | tap-spec',
'test:headless': 'node test/browser/webpack-test.js',
'test:browser': 'opener http://localhost:9007/test/browser/index.html && serve . -p 9007',
ci: 'npm run build && npm run test && npm run test:headless',
lint: 'standardx test/*.js index.js lib/*.js test/*/*.js',
clean: 'rm -rf node_modules dist/*.js test/browser/webpack-test.js',
prepublishOnly: 'npm run build'
}
Ah, for 1. and jest
the issue may be because it's a mono-repo... I believe npm show --json jest
is more aligned with
https://github.com/facebook/jest/blob/main/packages/jest/package.json rather than https://github.com/facebook/jest/blob/main/package.json
(40): The "jest" seems that is lacking appropriate testing (https://www.github.com/facebook/jest) (53): The "@openapitools/openapi-generator-cli" seems that is lacking appropriate testing (https://www.github.com/OpenAPITools/openapi-generator-cli)
Looking at
openapitools/openapi-generator-cli
it has a 'test' script in the package.json so maybe we need to expand what we check for.