@umijs/max v4, react 与 jest测试 #12814
Unanswered
nathanwkwong
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Zài yùnxíng react component de cèshì shí, Jest huì bàocuò
ReferenceError: React is not defined
. Version: @Umijs/max: ^4.1.1 React: ^18.2.0 Jest: ^29.7.0 Dāng wǒ zài xiāngguān component de file zhōng yǐnrù React néng jiějué.Import React from'react';
yǒu qítā fāngfǎ, bùyòng yǐnrù qù yùnxíng cèshì? 1. Zhǎo bù dào dìfāng yǐnrù babel configextraBabelPlugins: [ [ '@Babel/plugin-transform-react-jsx', { runtime: 'Automatic' } ] ]
2. Zài tsconfig.Json zhōng de compilerOptions.Jsx yòng"react" yě méiyǒu yòng. Xièxiè!顯示更多
438 / 5,000
在运行react component的测试时, Jest会报错
ReferenceError: React is not defined
。Version:
@umijs/max: ^4.1.1
react: ^18.2.0
jest: ^29.7.0
当我在相关component的file中引入React能解决。
import React from 'react';
有其他方法,不用引入去运行测试?
谢谢!
Beta Was this translation helpful? Give feedback.
All reactions