babel-jest

Requires Babel “^7.0.0-0”, but was loaded with “6.26.0”

允我心安 提交于 2020-06-11 17:07:05
问题 I have migrated my app to babel 7 beta and everything seems to work except the tests. I think I've read everything out there but I'm still getting this error: ● Test suite failed to run Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel

Requires Babel “^7.0.0-0”, but was loaded with “6.26.0”

て烟熏妆下的殇ゞ 提交于 2020-06-11 17:05:33
问题 I have migrated my app to babel 7 beta and everything seems to work except the tests. I think I've read everything out there but I'm still getting this error: ● Test suite failed to run Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel

babel@7 and jest configuration

旧巷老猫 提交于 2020-05-24 21:15:11
问题 Maybe you may help me? I try to configure jest to use babel@7 So I have: "jest": "^23.4.1", "@babel/core": "^7.0.0-beta.54", "babel-7-jest": "^21.3.3", "babel-jest": "^20.0.3", And jest config inside package.json "jest": { "transform": { "^.+\\.js$": "babel-7-jest", }, And got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string But if I use "jest": { "transform": { "^.+\\.js$": "babel-jest", }, I got Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are

babel@7 and jest configuration

大城市里の小女人 提交于 2020-05-24 21:14:32
问题 Maybe you may help me? I try to configure jest to use babel@7 So I have: "jest": "^23.4.1", "@babel/core": "^7.0.0-beta.54", "babel-7-jest": "^21.3.3", "babel-jest": "^20.0.3", And jest config inside package.json "jest": { "transform": { "^.+\\.js$": "babel-7-jest", }, And got TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string But if I use "jest": { "transform": { "^.+\\.js$": "babel-jest", }, I got Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are

`regeneratorRuntime` is not defined when running Jest test

非 Y 不嫁゛ 提交于 2020-04-07 17:38:10
问题 The title pretty much explains what I'm facing. I'm trying to test a React component that has some state, and I attempt to provide my store to the component in order to get what it needs. When I run the test of the component using Jest, I get the following error: ReferenceError: regeneratorRuntime is not defined I've determined through some reading that this is caused by babel-polyfill or regenerator-runtime not being applied correctly to Jest. However, I've tried installing both of those

getting jest to work with babel / laravel-mix

自作多情 提交于 2020-03-25 12:32:00
问题 I'm using jest and testing-library/react for tests of my ReactJS components in a Laravel app. My tests break because the component to to test isn't recognised by jest even after importing it into the test. I have the following settings in jest.config.js module.exports = { testRegex: 'resources/js/tests/.*.test.js$', roots: ["<rootDir>/resources/js/"], moduleDirectories: ["resources/js/components", "resources/js/containers", "resources/js/views", "node_modules"] } And in the package.json file

How to resolve “Cannot use import statement outside a module” in jest

ぃ、小莉子 提交于 2020-03-18 04:38:05
问题 I have a React application (not using Create React App) built using TypeScript, Jest, Webpack, and Babel. When trying to run "yarn jest", I get the following error: I have tried removing all packages and re-adding them. It does not resolve this. I have looked at similar questions and documentation and am still misunderstanding something. I went so far as to follow another guide for setting up this environment from scratch and still received this issue with my code. Dependencies include...

Cannot get Jest & React Native working

风格不统一 提交于 2020-02-24 12:14:06
问题 Trying to get Jest v12.1.1 working with React Native v0.26.2 I'm getting this error when run npm test : Error: Cannot find module 'ErrorUtils' from 'env.js' Here's my package.json . I'm trying to get this working with the default react-native init AwesomeProject starter. Is there something missing from my package.json? (are here any lines I don't need?) EXAMPLE 1: package.json { "name": "AwesomeProject", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react

Switching to babel 7 causes jest to show 'unexpected token'

依然范特西╮ 提交于 2020-02-16 06:29:11
问题 I am struggling with this jest error and have no idea how to fix it. Basically I ran the following commands to switch to new babel 7 : npx babel-upgrade --write --install npm install --save-dev @babel/preset-react npm install babel-polyfill Here is my package.json where all of the configs are specified (no .babelrc , no jest.config.js ): { "name": "seqr", "version": "0.2.0", "homepage": "", "devDependencies": { "@babel/cli": "^7.0.0", "@babel/core": "^7.0.0", "@babel/plugin-proposal-class

TypeError: Cannot read property 'email' of undefined props using Jest and React. Why?

蹲街弑〆低调 提交于 2020-01-24 20:32:08
问题 Trying to write unit tests for the ReactJs code using Jest. When I am trying to pass the props it shows me below error TypeError: Cannot read property 'email' of undefined 62 | 63 | const mapStateToProps = state => { > 64 | const { email, password, errors, loading } = state.auth; | ^ 65 | 66 | return { email, password, errors, loading }; 67 | }; SignIn.js import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import { Link } from