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.
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',
]
}
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.
I think it makes sense to add setupTestFrameworkFiles and deprecate the other to better match setupFiles. I also agree that keeping it in config is nicer.
@rickhanlonii @thymikee thoughts?
Yup, agreed with @SimenB plan
+1 to this proposal
I鈥檓 delighted to make this config option more useable and less verbose by dropping Script from the name, as that鈥檚 caught me out many of times :laughing:
Yeah, more consistency with setupFiles 馃檪
should we rename this to setupTestRunnerFiles to be more compatible with jest-circus being a testRunner??
Not sure, as it doesn't really modify/setup the runner itself. I could probably be convinced quite easily, though
I wonder if we could dropFramework too?
Either setupTestFiles or testSetupFiles seem to reflect what is actually going on as these files are run before each test.
That said I appreciate this is subjective and could be bike shedding so happy to go with what you guys think :wink:
All we need to clearly communicate is that setupFiles run _before_ the test framework is injected, and setupTestFrameworkScriptFiles (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
It seems like @SimenB is on the right track with intent needing to be conveyed accurately.
On the topic of setupFiles, the docs state
The paths to modules that run some code to configure or set up the testing environment before each test.
Why not rename this to setupTestEnvironmentFiles?
On the topic of setupTestFrameWorkScriptFile, docs state again
The path to a module that runs some code to configure or set up the testing framework before each test.
Why not rename this to setupTestFrameWorkFiles?
Upcoming major (because of babel 7), so we can just deprecate the old one if needed
setupTestsBeforeJest, setupTestsAfterJest? A bit verbose, but descriptive names are more important than short names
I'm good with those names :+1:
Gonna have to re-record a few egghead lessons I'm working on :P But this is a great change!
I'd like to pick this up as my first contribution to the project.
Awesome, go ahead! Feel free to ask questions if you have any :)
@SimenB Decided to give this a try and just made a PR. Figured we can talk around the code on the PR.
Most helpful comment
All we need to clearly communicate is that
setupFilesrun _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