question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected this binding in setupFiles

See original GitHub issue

What 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:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
SimenBcommented, Apr 15, 2018

Is that possible to achieve in strict mode? And as Jest runs in strict, can we break out of it for the tests?

0reactions
github-actions[bot]commented, Apr 27, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
A list of paths to modules that run some code to configure or set up the testing environment. Each setupFile will be run...
Read more >
Jest setupTestFrameworkScriptFile or setupFiles ES6 syntax
I am new to jest. I encounter the error on circle CI. My setup.js file has ES6 syntax. Since the file on setupTestFrameworkScriptFile...
Read more >
Known Issues and Resolutions - IBM
Resolution: Verify the log files for a Port Bind exception and restart the HTTP Server Adapter instance with a Port that is not...
Read more >
DOM Testing React Applications with Jest | Codementor
handleClick.bind(this); } render() { return <div onClick={this. ... we will write this code at a setupFile which can be configured in Jest.
Read more >
Enable HTTPS on your web server
In order to use HTTPS, you need to obtain a server certificate and bind it to ... There is no unexpected behavior or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found