score:3

Accepted answer

you configured babel in your webpack config and this will only apply to webpack. when other tools, like jest, use babel, they won't see that configuration because they don't look at the webpack config. you can use a .babelrc file to configure babel and that will apply to anything that runs babel (not just webpack).

using a .babelrc is usually preferred as you want to have a general babel config, and if you need to override a setting, you can still do that in the specific application like in the webpack config.

create the following .babelrc:

{
  "presets": ["es2015", "react"]
}

with that, you can remove the presets option in your webpack config because it will use the .babelrc. note that the cachedirectory option is specific to babel-loader and is not used to configure the underlying babel.

you also have a typo in your test, tomatchsnapshot() should be tomatchsnapshot().

expect(rendered.tojson()).tomatchsnapshot();

Related Query

More Query from same tag