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.

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:closed
  • Created 5 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
SimenBcommented, Sep 4, 2018

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

2reactions
ddrukercommented, Oct 8, 2018

@SimenB Decided to give this a try and just made a PR. Figured we can talk around the code on the PR.

Read more comments on GitHub >

github_iconTop 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 >

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