Allow setupTestFrameworkScriptFile to accept an array (or add a new config option that does)
See original GitHub issue🚀 Feature Proposal
I would like to pass multiple files to be run immediately before each test file is run but after the test framework has been loaded. This would either amount to extending setupTestFrameworkScriptFile
to accept an array of files, or a new config option (setupTestFrameworkFiles
?) to allow this.
Motivation & Example
I can change this:
// setupTestFrameworkScriptFile.js
import 'jest-dom/extend-expect'
import 'react-testing-library/cleanup-after-each'
Into this:
// jest.config.js
module.exports = {
// ...
setupTestFrameworkFiles: [
'jest-dom/extend-expect',
'react-testing-library/cleanup-after-each',
]
}
Pitch
This would simplify the project because the fact that setupFiles
accepts an array and setupTestFrameworkScriptFile
only accepts a string is confusing. It would also mean I don’t have to create a file with two lines of code which would be nice. This would also make extending toolkit with a built-in setupTestFrameworkScriptFile
with some custom behavior for the project.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Option "setupTestFrameworkScriptFile" was replaced by ...
I renamed my jest.config.js to setUpTests.js however that did not remove the deprecated error warning. import { configure } from ...
Read more >Configuring Jest
Here is how to enable it globally (additional options are not supported):. JavaScript; TypeScript. /** @type {import('jest').Config} */
Read more >Configuring package.json · Jest
Jest's configuration can be defined in the package.json file of your project or through the --config <path/to/json> option.
Read more >@humanwhocodes/config-array - npm
When you create a new instance of ConfigArray , you must pass in two arguments: an array of configs and an options object....
Read more >Configuring Jest Jest官方教程 _w3cschool - 编程狮
These options let you control Jest's behavior in your package.json file. ... The bail config option can be used here to have Jest...
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
All we need to clearly communicate is that
setupFiles
run before the test framework is injected, andsetupTestFrameworkScriptFiles
(or whatever it ends up being named) is run after. I don’t think either name really does that ATM, but it is what it is@SimenB Decided to give this a try and just made a PR. Figured we can talk around the code on the PR.