[Feature]: Allow `globalSetup` to access things in `globals`
See original GitHub issue🚀 Feature Proposal
Include globals
in global config so that globalSetup
or globalTeardown
can use it.
Motivation
I notice that Jest has globals
, but it isn’t included in global config. When I look at name globals
, I was thinking about it would be included in global config. So it would match with things related to “global”.
I have a use case https://github.com/thymikee/jest-preset-angular/issues/1348 which if Jest allows globals
to be in global config, it will look beautiful.
Example
Define in Jest config
// jest.config.js
//...
globals: {
'ngcc': { project: 'tsconfig.spec.json' },
}
In a globalSetup
script
import type { Config } from '@jest/types';
export = async (globalConfig: Config.GlobalConfig) => {
console.log(globalConfig.globals);
}
Pitch
This would be a change in Jest config. I think it should be in core.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Jest Global Setup - Part 10 - YouTube
Learn how to create a global setup when testing with Jest.
Read more >Globals - Jest
Globals. In your test files, Jest puts each of these methods and objects into the global environment. You don't have to require or...
Read more >Getting Jest global setup and global teardown to work in a ...
I want to run a function that opens db connection before running tests (global setup) and another function that closes db connection after ......
Read more >Jest Globals - w3resource
The only thing you need in a test file is the test method which will run a test. For instance, let's say there...
Read more >Globals · Jest
This is often useful if you want to clean up some global setup state that ... let globalDatabase = makeGlobalDatabase(); function cleanUpDatabase(db) {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, that’s what I meant in https://github.com/facebook/jest/issues/12436#issuecomment-1046203834
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.