Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused (non-Jest) test files in npm packages break Haste #51

Closed
ide opened this issue May 22, 2014 · 4 comments
Closed

Unused (non-Jest) test files in npm packages break Haste #51

ide opened this issue May 22, 2014 · 4 comments

Comments

@ide
Copy link
Contributor

ide commented May 22, 2014

I created a small demo repo with a single JS module and a single test.

mkdir moof && cd moof
git init
npm init
npm install --save clamp
touch moof.js
mkdir __tests__ && touch __tests/moof-test.js
git add .
git commit -m 'Initial commit'

Then edit moof.js:

require('clamp')

And moof-test.js:

jest.dontMock('../moof');

describe('moof', function() {
  it ('moofs', function() {
    var moof = require('../moof');
  });
});

Run jest -o:

$ jest -o
Using Jest CLI v0.1.12
Looking for changed files...

/usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:126
                    throw e;
                          ^
Error: Cannot find module 'tape' from '/Users/ide/tmp/moof/node_modules/clamp'
  at Function.module.exports [as sync] (/usr/local/lib/node_modules/jest-cli/node_modules/resolve/lib/sync.js:32:11)
  at Loader._nodeModuleNameToPath (/usr/local/lib/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:472:20)
  at Loader._moduleNameToPath (/usr/local/lib/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:447:19)
  at Loader._getNormalizedModuleID (/usr/local/lib/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:343:31)
  at Loader._getDependencyPathsFromResource (/usr/local/lib/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:302:12)
  at Loader.getDependentsFromPath (/usr/local/lib/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:697:34)
  at /usr/local/lib/node_modules/jest-cli/src/TestRunner.js:171:35
  at _fulfilled (/usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:798:54)
  at self.promiseDispatch.done (/usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:827:30)
  at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:760:13)
  at /usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:574:44
  at flush (/usr/local/lib/node_modules/jest-cli/node_modules/q/q.js:108:17)
  at process._tickCallback (node.js:419:13)

Inside node_modules/clamp there is a file called test.js that requires tape. We don't have tape because it's a dev dependency and also test.js is not needed. Haste should be smarter about the files it scans... this might be tricky because technically one could require clamp/test (from PHP even...) and it's just hard to statically tell what files are actually used.

@jeffmo
Copy link
Contributor

jeffmo commented May 23, 2014

Ah, yea this is probably an error that we should just swallow when doing the dependency calculation inside HasteModuleLoader.getDependentsFromPath(), I guess.

@jeffmo
Copy link
Contributor

jeffmo commented Jun 1, 2014

Ok, I believe this should be fixed in d397b4e

It will still console.warn() to tell you that it couldn't find the module -- but it won't fatal

@ghost
Copy link

ghost commented Aug 4, 2015

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

@cpojer cpojer closed this as completed Oct 16, 2015
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants