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.

Unknown option: base.configFile error when running tests

See original GitHub issue

Note from Maintainers

This is reportedly an issue with npm, as you will find below.

Please install Yarn as it’s reportedly correctly hoisting packages, preventing this error.

If you’d like to continue using npm, run npm ls babel-core and remove offending packages that are relying on 6.x. Additionally, file a bug report with npm.


Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes npm --version 6.4.1

Which terms did you search for in User Guide?

jest, test, babel, Unknown option: base.configFile

Environment

Environment: OS: macOS 10.14 Node: 8.10.0 Yarn: 1.6.0 npm: 6.4.1 Watchman: 4.9.0 Xcode: Xcode 10.0 Build version 10A255 Android Studio: Not Found

Packages: (wanted => installed) react: ^16.4.2 => 16.5.2 react-dom: ^16.4.2 => 16.5.2 react-scripts: 2.0.3 => 2.0.3

Steps to Reproduce

  1. Migrate from create-react-app v1.1.5 following the guide at https://github.com/facebook/create-react-app/releases
  2. Run the dev server and verify the app works correctly (npm start)
  3. Run all tests with npm test followed by a

Expected Behavior

Tests should run and complete

Actual Behavior

I get the following error on every test

Test suite failed to run

    ReferenceError: [BABEL] {redacted}/src/setupTests.js: Unknown option: base.configFile. Check out http://babeljs.io/docs/usage/options/ for more information about options.

    A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

    Invalid:
      `{ presets: [{option: value}] }`
    Valid:
      `{ presets: [['presetName', {option: value}]] }`

    For more detailed information on preset configuration, please see https://babeljs.io/docs/en/plugins#pluginpresets-options.

      at Logger.error (node_modules/babel-core/lib/transformation/file/logger.js:41:11)
      at OptionManager.mergeOptions (node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20)
      at OptionManager.init (node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
      at File.initOptions (node_modules/babel-core/lib/transformation/file/index.js:212:65)
      at new File (node_modules/babel-core/lib/transformation/file/index.js:135:24)
      at Pipeline.transform (node_modules/babel-core/lib/transformation/pipeline.js:46:16)

my setupTests.js file contains the following

import 'react-testing-library/cleanup-after-each';
import 'jest-dom/extend-expect';

Adding them to a fresh app doesn’t cause an issue.

Reproducible Demo

This is an internal project, but I’ll work to see if I can narrow it down at all and reproduce in a fresh install. So far I haven’t figured it out. I’m putting this issue up in the meantime to see if anyone else runs into it while migrating to v2. It also popped up at https://github.com/facebook/create-react-app/issues/5103#issuecomment-425722592, but clearing the node modules / lock / &c didn’t help, nor did upgrading to node v10.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:58 (11 by maintainers)

github_iconTop GitHub Comments

14reactions
jambyungcommented, Oct 10, 2018

@JaccoGoris Good to hear that! I also found that explicitly installing the bridge package with npm install -D babel-core@7.0.0-bridge.0 also fixes the issue without uninstalling jest-junit.

So I think there are 2 methods that you can try to fix this issue.

  1. remove package-lock.json, node_modules, and re-install packages.
  2. If method 1 does not solve, simply install babel-core@7.0.0-bridge.0 package ( preferably into your devDependencies ).

I recommend running npm ls babel-core to figure out which package is causing problem inside your dependency tree first.

7reactions
jambyungcommented, Oct 10, 2018

Hi, @JaccoGoris I cloned your repo and got the same config error. At first I thought it could be node issue so used 6.14.4, 7.10.1, but all failed.

I had the same issue with my repo and I found that the issue could be from babel-core still using 6.26.3 for some packages so I compared the dependency tree of both my project and yours.

$ npm ls babel-core

My project:

└─┬ react-scripts@2.0.3
  β”œβ”€β”€ babel-core@7.0.0-bridge.0
  └─┬ jest@23.6.0
    └─┬ jest-cli@23.6.0
      β”œβ”€β”¬ jest-config@23.6.0
      β”‚ └─┬ babel-core@6.26.3
      β”‚   └─┬ babel-register@6.26.0
      β”‚     └── babel-core@6.26.3
      └─┬ jest-runtime@23.6.0
        └── babel-core@6.26.3

Your project:

β”œβ”€β”¬ jest-junit@5.2.0
β”‚ └─┬ jest-config@23.6.0
β”‚   └─┬ babel-core@6.26.3
β”‚     └─┬ babel-register@6.26.0
β”‚       └── babel-core@6.26.3  deduped
└─┬ react-scripts@2.0.4
  β”œβ”€β”€ babel-core@7.0.0-bridge.0
  └─┬ jest@23.6.0
    └─┬ jest-cli@23.6.0
      └─┬ jest-runtime@23.6.0
        └── babel-core@6.26.3  deduped

I found that on my project, babel-core@7.0.0-bridge.0 is on the top level of the dependency tree, above any other subtrees that uses babel 6.26.3.

So I did following and npm test worked like a charm.

  • uninstall jest-junit
  • remove package-lock.json
  • remove node_modules
  • run npm install again

And the dependency tree of babel-core should look like following when you run npm ls babel-core:

└─┬ react-scripts@2.0.4
  β”œβ”€β”€ babel-core@7.0.0-bridge.0
  └─┬ jest@23.6.0
    └─┬ jest-cli@23.6.0
      β”œβ”€β”¬ jest-config@23.6.0
      β”‚ └─┬ babel-core@6.26.3
      β”‚   └─┬ babel-register@6.26.0
      β”‚     └── babel-core@6.26.3
      └─┬ jest-runtime@23.6.0
        └── babel-core@6.26.3

Hope this helps.

Edit: seems like explicitly installing babel-core@7.0.0-bridge.0 also solves the issue. And make sure you clear jest cache before re-trying. With jest cache every subsequent test will succeed

$ npm install -D babel-core@7.0.0-bridge.0

npm ls babel-core will show following:

β”œβ”€β”€ babel-core@7.0.0-bridge.0
β”œβ”€β”¬ jest-junit@5.2.0
β”‚ └─┬ jest-config@23.6.0
β”‚   └─┬ babel-core@6.26.3
β”‚     └─┬ babel-register@6.26.0
β”‚       └── babel-core@6.26.3
└─┬ react-scripts@2.0.4
  β”œβ”€β”€ babel-core@7.0.0-bridge.0
  └─┬ jest@23.6.0
    └─┬ jest-cli@23.6.0
      └─┬ jest-runtime@23.6.0
        └── babel-core@6.26.3
Read more comments on GitHub >

github_iconTop Results From Across the Web

Module build failed: ReferenceError: [BABEL] Unknown option
I had this problem and I fixed it by eliminating the query in the config file and instead making a .babelrc file at...
Read more >
while running the test i am getting this error,can anyone help ...
Test suite failed to run. ReferenceError: [BABEL] /Users/Documents/my-app/src/setupTests.js: Unknown option: base.configFile.
Read more >
Configuring Jest
By default, Jest runs all tests and produces all errors into the console upon completion. The bail config option can be used here...
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 >
Testrunner - WebdriverIO
wdio repl <option> [capabilities] Run WebDriver session in command line wdio run <configPath> Run your WDIO configuration file to initialize your tests.
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 Hashnode Post

No results found