[英]How to fix Jest encountered an unexpected token
我用 babael 配置了我所有的玩笑,但我無法運行測試,它總是顯示相同的錯誤。 我正在使用帶有樣式組件的 nextJs 和 typescript。 失敗 src/components/Main/main.spec.tsx ● 測試套件運行失敗 快照:0 總時間:3.841 s 運行所有測試套件。 ...
[英]How to fix Jest encountered an unexpected token
我用 babael 配置了我所有的玩笑,但我無法運行測試,它總是顯示相同的錯誤。 我正在使用帶有樣式組件的 nextJs 和 typescript。 失敗 src/components/Main/main.spec.tsx ● 測試套件運行失敗 快照:0 總時間:3.841 s 運行所有測試套件。 ...
[英]Problem with Project Dependency Tree (babel-jest/reactjs)
我是 ReactJS 的新手,並且在我正在處理的構建中弄亂了 Material UI。 我安裝了 package,它完全搞砸了我的構建和打開服務器的能力。 當我做npm start 我收到以下錯誤: `> 反應腳本開始項目依賴樹可能有問題。 這可能不是 Create React App 中 ...
[英]TypeError: Cannot read property 'type' of null - testing vue component with async functions
我正在測試組件 ComponentA.spec.js 但我收到TypeError: Cannot read property 'type' of null 。 如果我去掉 ComponentA 中 getData() function 中的 await 關鍵字,它就會起作用。 我是 mocking ...
[英]Jest encountered an unexpected token
我剛剛開始用玩笑學習反應測試庫,並創建了一個示例應用程序來模擬服務器。我的節點版本是 v16.13.0。 但是,我收到以下錯誤“SyntaxError:無法在模塊外使用導入語句”。 我什至寫了 import axios from './lib/axios' 但我得到了同樣的錯誤。 我的測試 這是我的 ...
[英]Computed method/property decorators are not yet supported
我有錯誤 my.babelrc.json 是 我正在將https://github.com/tunnelvisionlabs/antlr4ts中的代碼復制到我的存儲庫中以進行嘗試。 但是當我運行jz test時,出現了上述錯誤。 看來我需要使用 babel 插件來編譯 antlr4ts 源代碼。 ...
[英]waitFor in Jest doesn't wait for setTimeOut no matter how long
我正在使用 Formik 為 React 網絡應用程序創建表單。 提交如下代碼。 const submitForm = (values) => { console.log(JSON.stringify(values, null, 2)); setFormStatus(st ...
[英]Jest/React testing error "SyntaxError: Private field '#root' must be declared in an enclosing class"
我是測試 React 組件的新手,我在這里經常遇到錯誤。 這與我正在測試的組件的嵌入式組件中的 CSS 導入有關: 該錯誤發生在我正在測試的組件的嵌入式組件 (NavBar) 上。 我正在測試的組件(着陸)和測試: 發生錯誤的組件: 測試文件(不完整,我只是暫時測試組件渲染): jest 和 b ...
[英]Local image import in nextjs with jest (react-testing-library) failed
針對我的主頁編寫測試用例時出現以下錯誤,其中包含着陸圖像。 我在 jest.config.js 文件中嘗試了下面建議的解決方案,但無法解決這個問題。 此外,我嘗試了以下站點中建議的所有解決方案。 導入圖像會破壞玩笑測試 ...
[英]Jest ReferenceError: Cannot access before initialization
我的服務.ts 我的服務.test.ts 如果我運行測試,我會收到以下錯誤。 ReferenceError:初始化前無法訪問“getDeciderMock” 我讀了很多關於開玩笑如何主持的文章,但沒有任何幫助。 任何人都遇到過類似的問題並且知道解決方案嗎? 我為此使用 TypeScript,開玩笑 ...
[英]How to test throw error in error event using Jest
我對那個學習案例有疑問。 我有以下代碼,我想測試拋出錯誤: 測試: ...
[英]How can we collect code coverage report from a file with "es" extension in jest?
我正在嘗試從擴展名為“es”的文件中收集代碼覆蓋率(即 sum.es)(這里的es表示ECMA 腳本)。 這是文件夾結構的樣子 我能夠運行兩個測試文件( sum.test.js , sum.test.es ) 但無法為sum.es文件生成代碼覆蓋率。 jest.config.js 文件: 誰 ...
[英][Jest Unit Testing]: TypeError: component.setState is not a function
我們正在使用 Jest 進行單元測試。 我們有一個包含公共 OnChange() function 定義的公共文件。 在為 OnChange 編寫單元測試用例時,拋出以下錯誤: 例如通用函數.tsx 從 class 組件調用 OnChange: OnChange 的 Jest 單元測試用例:C ...
[英]Jest mock redux toolkit actions/store files
我在 React.js 應用程序中使用 Redux 工具包,我提取的邏輯如下: 商店.tsxconst history = createHashHistory(); const middleware = [ ...getDefaultMiddleware().concat(routerMid ...
[英]Error: Uncaught [TypeError: Cannot destructure property 'match' of 'props.value' as it is undefined.]
這里編寫了 header.js 代碼,並使用 jest 框架進行測試。 在我測試時,我得到了 props.value 匹配的錯誤屬性,因為它是未定義的。 當我編譯時,編譯器顯示此鏈接以解決錯誤但它沒有得到。 [鏈接:] https://reactjs.org/link/error-boundar ...
[英]Jest filter filter returns 0 matches
我正在使用 Jest v26.6.3,我正在嘗試創建一個過濾器以編程方式 select 運行什么測試。 我正在關注有關如何設置過濾器文件的文檔,這看起來很簡單,但 jest 返回Pattern: - 0 matches ,無論我指定的模式如何。 PS:如果我從 CLI 參數中刪除過濾器,jest ...
[英]Jest TypeError: Cannot read property 'id' of undefined
看不懂怎么指定id,我是初學者,希望對大家有所幫助。 一開始的錯誤是:TypeError:無法讀取未定義的屬性'0' 首先和路徑但是當我添加到測試文件 mockResolvedValue({allEmployees: '',}) 它消失了,一個新的出現了 js文件 test.js 文件 錯誤 ...
[英]Jest tests started failing with "Cannot use import statement outside a module" after using jail-monkey package in my React Native application
我有一個 React Native 應用程序,我在其中安裝並使用 jail-monkey 來檢查設備是否已植根。 一旦我添加它,我的一些 Jest 測試就開始失敗並出現以下錯誤: 谷歌搜索后,我發現了這個堆棧溢出線程,它有很多答案,但都沒有幫助我。 話雖如此,我想這個問題與 babel 和 jes ...
[英]next.js + typescript + jest Unexpected token 'export'
當我嘗試在我的 Typescript Next.js 項目中運行 jest 時,我收到此錯誤: 我已經嘗試在我的 jest 配置中將 d3-scale 添加到 transformIgnorePatterns。 ...
[英]Jest(React) syntax error, configuration problem after the run of jest coomand
我在 package.json 文件中使用了這些包 也有這樣的笑話配置 Setup.tests.js 文件位於包含內容的根文件夾中 ** ** 當我運行jest --runInBand --ci --verbose true我得到了 您將在文檔中找到這些配置選項的更多詳細信息和示 ...
[英]Why does Jest keep giving me error "SyntaxError: Cannot use import statement outside a module' "? I am using Babel to transpile ES6 for Jest to test
為什么我在使用 Babel 和 Jest 時不斷收到錯誤消息“SyntaxError: Cannot use import statement outside a module”? 我有一個超級簡單的應用程序,其中包含兩個模塊: // moduleTwo.mjs: /////////// ...