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

Unexpected strict mode reserved word syntax error when mocking express #284

Closed
lcapel opened this issue Jan 11, 2024 · 2 comments · Fixed by #287
Closed

Unexpected strict mode reserved word syntax error when mocking express #284

lcapel opened this issue Jan 11, 2024 · 2 comments · Fixed by #287

Comments

@lcapel
Copy link

lcapel commented Jan 11, 2024

Hello, I'm having a little bit of trouble when it comes to mocking express. When I attempt to do so I get a SyntaxError telling me that I'm using and unexpected strict mode reserved word.

I'm using node 20 and mocha as the testing framework.

I have no issues mocking other libraries, just express. I made this minimal example in codesanbox.io to illustrate the issue: https://codesandbox.io/p/devbox/busy-pare-xfv7gy

@iambumblehead
Copy link
Owner

@lcapel sorry for the delayed response adding this to the mock object that is produced from express allows the test to pass delete def.static

the exported "static" value is here, link

exports.static = require('serve-static');

@lcapel
Copy link
Author

lcapel commented Jan 15, 2024

@iambumblehead thank you for the quick fix everything is working as expected now!

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

Successfully merging a pull request may close this issue.

2 participants