-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
stub/spy a function #1819
Comments
That should work. |
We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question; please post it to StackOverflow and tag it with If you feel that your topic is an issue with Sinon, please open a new ticket and follow the guidelines for reporting an issue. |
@mroderick This has been asked and answered multiple times, but I guess this ultimately points to us needing to have more how-tos/docs. This touches somewhat on the link seams, but people get confused when encountering ES6 and all the mess that entails (ES6 -> ES5 transpilation, "true" immutable ESM modules versus the ones loaded using ESM with and without the Not asking you, btw, merely noting it :-) |
@fatso83 you understand this issue much better than I do 😉 |
Since all of my source code files are mjs files, sinon reports the following error message. It seems that we have to wait for the support of ES module.
|
@jim-king-2000 No, shipping Sinon as a ES6 module has nothing to do with that. You need to use the mutableNamespace option I mentioned above using the |
Hi @fatso83 , I need the docs about stubbing ES6 modules. No matter how I try, I always get the same error, 'ES Modules cannot be stubbed'. |
@jim-king-2000 You already got the docs ... it was the link to the NPM module. But anyway ... you might want to check out this thread: #1803 (comment) It is the author of |
P.S If you need any more help, @jim-king-2000, please post a question to StackOverflow and tag it with |
I read the thread and I still have no idea how to do. I use AVA + sinon with esm and I do not use babel. The following is my config. I'll post the question to StackOverflow ASAP. By the way, I insist that it is an issue, a doc issue is still an issue.
|
Agreed. Added #1832. Did not find your question on SO, btw. |
I'm writing it. Thanks for the help and the advise. |
Here's the link: https://stackoverflow.com/questions/50763323/stub-a-function-from-a-es6-module-without-babel. Thank you again. |
I have a pure function.
How can I stub/spy it in a test file? The following code does not work. It seems sinon can only stub obj.method.
The text was updated successfully, but these errors were encountered: