Unexpected this binding in setupFiles
See original GitHub issueWhat is the current behavior?
The value of this
in a setupFile is a plan Object. The equivalent file when invoked in a browser would have this=Window
.
This is important in my scenario because the framework I’m trying to load is jqlite which passes this to the setup factory and expects to be able to attach it to that root object for use later.
What is the expected behavior?
I could be missing something but I would have thought, since jest provides a jsdom runtime with a defined Window object that scripts executed as part of setup (setupFiles and setupTestFrameworkScript) should be bound to the jsdom window.
Or perhaps this should be an option that I can pass to the wrapper so that when a setupFile is invoked it can be given a context?
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system. Jest 22.4.2 Node 8.9.4 / npm 5.6 Windows 10
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top GitHub Comments
Is that possible to achieve in strict mode? And as Jest runs in strict, can we break out of it for the tests?
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.