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

Access to jest runtime from setupTestFrameworkScriptFile #108

Closed
simenbrekken opened this issue Aug 5, 2014 · 3 comments
Closed

Access to jest runtime from setupTestFrameworkScriptFile #108

simenbrekken opened this issue Aug 5, 2014 · 3 comments

Comments

@simenbrekken
Copy link

I'd like to add some more mocking methods to jest but there doesn't seem to be an easy way to add methods to the jest object.

@lxanders
Copy link

lxanders commented Dec 1, 2014

This is a problem for me too.

There are scripts that are meant to run before the tests. These two are the ones that sound good for executing code :

The path to a module that runs some code to configure or set up the testing framework before each test. Since config.setupEnvScriptFile executes before the test framework is installed in the environment, this script file presents you the opportunity of running some code immediately after the test framework has been installed in the environment.

The path to a module that runs some code to configure or set up the testing environment before each test. Since every test runs in it's own environment, this script will be executed in the testing environment immediately before executing the test code itself.
It's worth noting that this code will execute before config.setupTestFrameworkScriptFile.

Reading this it sounds like the script specified by setupTestFrameworkScriptFile is the latest moment you can pre run code before the tests are started. I can confirm that there seems to be no way to access the jest object in these files.

One good reason for exposing the jest object: We had massive problems with the auto mocking and disabling it fixed the problems for us. As there is no configuration option for disabling this per run, you have to call jest.autoMockOff(); in each test. Moving this out in a pre run script would have been an acceptable workaround for the missing config / run switch for it.

@ncuillery
Copy link
Contributor

👍

johannhof pushed a commit to johannhof/jest that referenced this issue May 6, 2015
DmitrySoshnikov added a commit that referenced this issue May 8, 2015
Pass jest runtime to test setup scripts (closes #108)
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants