Jest config with everything that meteor supports

Hi there,

I’m very new to testing and couldn’t find a solution to the very first problem. After installing jest and adding a test file, it seems jest doesn’t understand the ES6 syntax. I tried installing babel-preset-meteor and added it to my .babelrc but it still doesn’t work. If I add @babel/preset-env, it understands the import statements but then it complains about missing plugins.

Anyone can share a basic jest/babel config which works with everything that meteor supports?

This is a .babelrc I’m using. The test environment is used by jest.

{
  "plugins": [
    "add-react-displayname",
    "@babel/plugin-transform-flow-strip-types",
    "@babel/plugin-proposal-optional-chaining"
  ],
  "env": {
    "test": {
      "presets": [
        "module:babel-preset-meteor",
        "@babel/preset-env",
        "@babel/preset-react"
      ],
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        "module:babel-root-slash-import"
      ]
    },
    "meteor:test": {
      "plugins": ["rewire"]
    }
  }
}
1 Like