当我运行测试时,即使测试有效,它也会向我发送警告。经过一些研究,我似乎必须把它放在一个,act但它是同一件事
console.error
Warning: An update to Formik inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
)
at printWarning (node_modules/react-dom/cjs/react-dom.development.js:67:30)
at error (node_modules/react-dom/cjs/react-dom.development.js:43:5)
at warnIfNotCurrentlyActingUpdatesInDEV (node_modules/react-dom/cjs/react-dom.development.js:24064:9)
at dispatch (node_modules/react-dom/cjs/react-dom.development.js:16135:9)
at node_modules/formik/src/Formik.tsx:327:11 …Run Code Online (Sandbox Code Playgroud) 在我的 CRA 项目中,每次运行它时,我都会在控制台中遇到此错误。我认为这是由于打字稿服务器造成的。有办法解决吗?
99% done plugins webpack-hot-middlewarewebpack built preview 7c330f0bfd3e44c3a97b in 6446ms
Issues checking in progress...
<--- Last few GCs --->
[15997:0x7fccd3700000] 618460 ms: Mark-sweep (reduce) 2043.8 (2082.1) -> 2042.4 (2082.1) MB, 3304.1 / 0.0 ms (average mu = 0.202, current mu = 0.179) allocation failure scavenge might not succeed
[15997:0x7fccd3700000] 622127 ms: Mark-sweep (reduce) 2043.5 (2082.1) -> 2042.4 (2081.8) MB, 3661.0 / 0.0 ms (average mu = 0.106, current mu = 0.002) allocation failure scavenge might not succeed
<--- …Run Code Online (Sandbox Code Playgroud) 从昨天开始,我在 github 操作上运行单元测试时遇到了这个错误,我不明白为什么会发生这个错误。你能帮我解决这个问题吗?
> whisper-ui@1.0.0 test
> react-scripts test --coverage --watchAll=false --updateSnapshot
#
# Fatal error in , line 0
# Check failed: !holder_map.has_named_interceptor().
#
#
#
#FailureMessage Object: 0x7ffd7ab08610
1: 0xb691f1 [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
2: 0x1bf3094 V8_Fatal(char const*, ...) [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
3: 0x10ac4a1 v8::internal::compiler::JSGlobalObjectRef::GetPropertyCell(v8::internal::compiler::NameRef const&, v8::internal::compiler::SerializationPolicy) const [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
6: 0x1e61ba3 v8::internal::compiler::JSNativeContextSpecialization::ReduceNamedAccess(v8::internal::compiler::Node*, v8::internal::compiler::Node*, v8::internal::compiler::NamedAccessFeedback const&, v8::internal::compiler::AccessMode, v8::internal::compiler::Node*) [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
这是我为 github action 编写的 yaml 代码
web_test:
name: Web Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x, 16.x]
steps: …Run Code Online (Sandbox Code Playgroud)