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

Failing bindings #2

Closed
reflog opened this issue Sep 15, 2016 · 17 comments
Closed

Failing bindings #2

reflog opened this issue Sep 15, 2016 · 17 comments

Comments

@reflog
Copy link

reflog commented Sep 15, 2016

Hi. I've opened this issue in Jest repo initially, but later found out that it was due to my usage of ts-jest.

jestjs/jest#1694

Could you take a look please? I've made a repo to show how to reproduce the bug:

https://github.com/reflog/jest_bug_test

@kulshekhar
Copy link
Owner

I'll take a look at it

@kulshekhar
Copy link
Owner

@reflog when I run npm test, I get the following:

No tests found
No files found in .../jest_bug_test.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest API Documentation: facebook.github.io/jest/docs/api.html

Can you help me reproduce the error you're getting?

@reflog
Copy link
Author

reflog commented Sep 15, 2016

This is odd. Just checked that all my code is committed, ran the test again:

[~/dev/tmpz/jest_bug_test]$ npm test

> jest_bug_test@1.0.0 test /home/reflog/Rafael/tmpz/jest_bug_test
> jest

  console.warn node_modules/node-uuid/uuid.js:48
    [SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()

 FAIL  __tests__/test.ts
  ✕ test1 (181ms)

  ● test1

    Could not locate the bindings file. Tried:
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/build/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/build/Debug/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/build/Release/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/out/Debug/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/Debug/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/out/Release/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/Release/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/build/default/deasync.node
     → /home/reflog/dev/tmpz/jest_bug_test/node_modules/deasync/compiled/6.5.0/linux/x64/deasync.node

      at bindings (node_modules/bindings/bindings.js:88:9)
      at node_modules/deasync/index.js:34:32
      at Object.<anonymous> (node_modules/deasync/index.js:76:2)
      at Object.<anonymous> (node_modules/node-etcd/lib/client.js:7:11)
      at Object.<anonymous> (node_modules/node-etcd/lib/index.js:9:10)
      at Object.<anonymous> (testModule.ts:3:12)
      at Object.<anonymous> (test.ts:4:11)
      at process._tickCallback (internal/process/next_tick.js:103:7)

Test Summary
 › Ran all tests.
 › 1 test failed, 0 tests passed (1 total in 1 test suite, run time 0.85s)
npm ERR! Test failed.  See above for more details.
[master][~/dev/tmpz/jest_bug_test]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
[master][~/Rafael/tmpz/jest_bug_test]$ 

@kulshekhar
Copy link
Owner

I'll check this on a fresh VM

@kulshekhar
Copy link
Owner

kulshekhar commented Sep 15, 2016

I was able to reproduce this on a fresh VM. The problem is neither jest nor ts-jest.

This error is caused by the deasync dependency which needs to be rebuilt using node-gyp. After running the following sequence of commands (in the jest_bug_test directory on a fresh VM running Ubuntu 16.04), npm test executed successfully:

sudo apt-get install -y python make build-essential
npm i -g node-gyp
cd node_modules/deasync
node-gyp rebuild
cd ../..
npm test

Closing this issue.

@reflog
Copy link
Author

reflog commented Sep 15, 2016

Thanks! But out of curiosity (and my lack of knowledge of node internals) - how does the code run without jest, but fails when ran with jest? How does it succeed without the node-gyp rebuild?

@kulshekhar
Copy link
Owner

When you don't use Jest, the code isn't invoked (the library in question doesn't need to be loaded)

If you created another file and tried to load testModule from it, you should see the same error even without using Jest.

@reflog
Copy link
Author

reflog commented Sep 15, 2016

If you don't mind helping out a fellow dev - i've commited an example to the same repo: https://github.com/reflog/jest_bug_test and added a small program to demonstrate that I can actually run the code using 'testModule' without node-gyp.

You can do 'npm run go' to run the test app - it will successfully import node-etcd and deasync.
Then you can run 'npm test' and it will fail because of the bindings.

I'm trying to understand - why is this happening.

Thanks in advance!

@kulshekhar
Copy link
Owner

If it's working in that way, I might have to take a closer look at it. I'll try to do that later today.

Reopening the issue for now.

@kulshekhar kulshekhar reopened this Sep 15, 2016
@kulshekhar
Copy link
Owner

Can you test this with a plain Javascript project, using jest but not ts-jest?

@reflog
Copy link
Author

reflog commented Sep 15, 2016

Tested. Using plain JS and Jest - works.

@kulshekhar
Copy link
Owner

I just converted this to JS and tested it. I'm seeing the same errors without ts-jest. Here's the repo of the converted code: https://github.com/kulshekhar/jest_bug_test

npm start works
npm test throws the same errors that you've reported

Can you test this repo and share your results?

@reflog
Copy link
Author

reflog commented Sep 15, 2016

Weird. I could swear it worked before. But you are right - this does not. I guess it is a Jest issue after all?

@kulshekhar
Copy link
Owner

kulshekhar commented Sep 15, 2016

That's what it looks like.

I'm closing this issue. Maybe you should reopen jestjs/jest#1694 and continue the discussion there?

Side note: I usually delete forked repos. Since you might want a copy to share on jest's issue tracker, let me know if you want me to leave this fork up for a while.

@reflog
Copy link
Author

reflog commented Sep 15, 2016

Yes, please leave it open. I'd reference both repos in Jest's tracker. Thanks for helping out!

@narkowicz
Copy link

Ran into the same issue - for the benefit of others, as per jestjs/jest#1694 (direct link) the issue is not including "node" in the "moduleFileExtensions" jest config setting.

The "node" module extension is included in the js defaults, but often omitted from example ts-jest configs.

@kulshekhar
Copy link
Owner

@narkowicz thanks for sharing that info. I've opened an issue to track this. Would it be possible for you to send a PR with moduleFileExtensions fixed everywhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants