-
Notifications
You must be signed in to change notification settings - Fork 128
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
Object.defineProperty called on non-object with mocha #56
Comments
I noticed the issue I had linked was the incorrect one. It's been fixed. |
Thx for the detailed report. Unfortunately I can't reproduce the error. After downloading the gist and running
|
Little mistake in the command, should be The node version case it is useful:
If I get a chance this week I will try to debug the issue. |
Did a quick look and it is because of the function name. The I don't know if there is a way to alert the user of this, or perhaps it can just be documented - if it's not already. edit: Added info on source of run global |
After looking into the source a little more I can't see a way to warn a user if a local variable is being overwritten by a injected global without using some sort of JavaScript parser. |
Thx for the detailed research. I was able to fix that problem by wrapping the source code inside an IIFE. |
Description
I believe that may be related to #51 given it produces the same error.
When using mocha and rewire with a module that exports a named function directly, an error occurs:
Running without mocha and using node directly works correctly.
Changing from a named function to assigning the function (see test files below) and exporting the variable instead works.
Example
Test Files
index.js
test.js
Gist
https://gist.github.com/MitMaro/eb09a24817bcc58f9421
Running
npm install
mocha index.js
Stacktrace
The text was updated successfully, but these errors were encountered: