Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths

Option "setupTestFrameworkScriptFile" was replaced by configuration "setupFilesAfterEnv", which supports multiple paths.

Please update your configuration.

I found this exact question here: setupTestFrameworkScriptFile is not supported error

I renamed my jest.config.js to setUpTests.js however that did not remove the deprecated error warning.

import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

configure({ adapter: new Adapter() })

package.json scripts

"scripts": {
  "dev": "next -p 7777",
  "build": "next build",
  "start": "next -p 7777",
  "test": "NODE_ENV=test jest --watch --no-cache",
  "test-win": "SET NODE_ENV=test&& jest --watch"
}
"@types/enzyme": "^3.1.15",
"@types/jest": "^23.3.13",
"jest": "^24.1.0"
like image 694
Leon Gaban Avatar asked Apr 18 '19 19:04

Leon Gaban


2 Answers

Jest used to have a config option called setupTestFrameworkScriptFile...

...but it was deprecated in favor of the newer setupFilesAfterEnv in PR #7119 which shipped with version 24.0.0.

Since you are using Jest ^v24.1.0 you will need to use setupFilesAfterEnv.

Just find where setupTestFrameworkScriptFile is used in your Jest config, rename it to setupFilesAfterEnv, and put the single file it used to point to in an array and you should be good to go.

Example, change this jest.config.js:

module.exports = {
  ...
  setupTestFrameworkScriptFile: './setup.js',
  ...
}

...to this:

module.exports = {
  ...
  setupFilesAfterEnv: ['./setup.js'],
  ...
}
like image 73
Brian Adams Avatar answered Oct 24 '22 03:10

Brian Adams


If you are using create-react-app, change the key name at package.json file

from

  "jest": {
    // ...
    "setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",

to

  "jest": {
    // ...
    "setupFilesAfterEnv": ["<rootDir>/src/setupTests.js"],
like image 27
Eric Avatar answered Oct 24 '22 03:10

Eric