dnt icon indicating copy to clipboard operation
dnt copied to clipboard

Do not search node_modules directories for test files

Open dsherret opened this issue 1 year ago • 1 comments

As title.

dsherret avatar May 29 '24 01:05 dsherret

Just ran into this via bl:

> node test_runner.js


Running tests in ./esm/node_modules/.deno/[email protected]/node_modules/bl/test/test.js...

node:internal/modules/cjs/loader:1143
  const err = new Error(message);
              ^

Error: Cannot find module 'tape'
Require stack:
- /Users/joscha/dev/a-node/npm/esm/node_modules/.deno/[email protected]/node_modules/bl/test/test.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/joscha/dev/a-node/npm/esm/node_modules/.deno/[email protected]/node_modules/bl/test/test.js:2:14)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at cjsLoader (node:internal/modules/esm/translators:366:17) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/joscha/dev/a-node/npm/esm/node_modules/.deno/[email protected]/node_modules/bl/test/test.js'
  ]
}

Node.js v20.12.2
error: Uncaught (in promise) Error: npm run test failed with exit code 1
      throw new Error(
            ^
    at runCommand (https://jsr.io/@deno/dnt/0.41.2/lib/utils.ts:56:13)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async build (https://jsr.io/@deno/dnt/0.41.2/mod.ts:419:5)
    at async file:///Users/joscha/dev/a-node/scripts/build_npm.ts:10:1

was able to work around this by using the rootTestDir option, e.g.:

rootTestDir: './src/tests',

joscha avatar Jun 04 '24 13:06 joscha