Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest fails when not using Babel #1850

Closed
ianp opened this issue Oct 3, 2016 · 4 comments
Closed

Jest fails when not using Babel #1850

ianp opened this issue Oct 3, 2016 · 4 comments

Comments

@ianp
Copy link

ianp commented Oct 3, 2016

Even the simplest project, as described in the Getting Started guide now fails.

Create the sample project (sum.js and sum.spec.js) and then try to run Jest, it fails with Couldn't find preset "es2015" relative to directory "/Users/ianp/Projects". Or check out this gist: https://gist.github.com/0e44151b16718ebc83bb25efb68a9395 .

In the debug configuration (below) I can see that it is setting usesBabelJest to true, although I'm not sure why that should be the base as I'm not using Babel in my project. I've tried adding usesBabelTest: false to package.json but that made no difference. I can also see that the preset seems to be null in the configuration, which seems odd given the error message 🤔

jest version = 16.0.0
test framework = jasmine2
config = {
  "rootDir": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395",
  "name": "-Users-ianp-Projects-0e44151b16718ebc83bb25efb68a9395",
  "setupFiles": [],
  "testRunner": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/jest-jasmine2/build/index.js",
  "scriptPreprocessor": "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395/node_modules/babel-jest/build/index.js",
  "usesBabelJest": true,
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/var/folders/5p/qfkdcjcj343gnxdn0cy8_6l40000gn/T/jest",
  "clearMocks": false,
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "globals": {},
  "haste": {
    "providesModuleNodeModules": []
  },
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "moduleNameMapper": {},
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "preprocessorIgnorePatterns": [
    "/node_modules/"
  ],
  "resetModules": false,
  "testEnvironment": "jest-environment-jsdom",
  "testPathDirs": [
    "/Users/ianp/Projects/0e44151b16718ebc83bb25efb68a9395"
  ],
  "testPathIgnorePatterns": [
    "/node_modules/"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "testURL": "about:blank",
  "timers": "real",
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "cache": true,
  "watchman": true,
  "testcheckOptions": {
    "times": 100,
    "maxSize": 200
  }
}
@cpojer
Copy link
Member

cpojer commented Oct 4, 2016

The preset must be coming from a .babelrc somewhere in your tree. If it's there, Jest will currently automatically use it.

@cpojer cpojer closed this as completed Oct 4, 2016
@cpojer
Copy link
Member

cpojer commented Oct 4, 2016

To fix:

  • Remove .babelrc
  • Install the ES2015 preset

@ianp
Copy link
Author

ianp commented Oct 4, 2016

Doh! there was a .babelrc file in a parent directory, not sure how that got there 😖

Thanks for the hint!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants