簡體   English   中英

如何修復Ember testem中的錯誤,例如“無法加載”,“失敗”,“無法找到模塊”或“死”?

[英]How can I fix tests in Ember testem with errors such as 'could not load', 'failed', 'could not find module' or 'died'?

我設法通過HTMLBars將幾個基於EAK / grunt的Ember應用程序升級到1.11,然后將它們遷移到Ember CLI / Brocolli。 單元測試是為業力測試運行程序而設置的,因此我正在研究如何使它們立即在CLI項目中運行,但是我沒有編寫測試,並且實際上沒有使用單元測試javascript模塊的經驗。

在iNet上搜索時,我看到其他人也因為其覆蓋范圍輸出而使用了業力,並試圖使其與Ember CLI一起使用,但是Ember Core不支持它,盡管他們說任何人都應該能夠得到它。它使用自定義插件進行設置。 我還嘗試使用“ testem”運行程序來了解其結果。

Ember網站確實有一個針對v1.10的“與跑步者一起進行自動化測試”頁面,其中包含有關“ testem”和“ karma”的部分,但是對於v1.11卻沒有出現,因此我無法從該網站中分辨出什么是或不相關。 但是似乎我應該能夠為業力測試運行者制定一個解決方案,因此我在項目package.json中添加了舊的devDependencies:

"karma": "^0.12.31",
"karma-chai": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-coverage": "~0.2.1",
"karma-firefox-launcher": "~0.1.3",
"karma-junit-reporter": "~0.2.1",
"karma-mocha": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2",
"karma-sinon-chai": "~0.1.5"

我還將舊的“ karma.conf.js”(以及其他一些karma conf)放入項目中,並更新了內部路徑(從“供應商”到“ bower_components”)。 我確實找到了一個'ember-cli-karma'節點模式並安裝了它,但似乎只有一個'package.json'。 它沒有文檔,似乎只是一個沒有實現的殘酷入門項目。 我還安裝了“ karma”,“ karma-cli”和“ testem”節點模塊。

testem文檔說要添加src和測試文件到“ testem.json”,但是沒有示例,我不知道那是什么意思。 每個src和測試文件的列表? 走什么路 相對的,絕對的? 正斜杠,反斜杠? 在/或./或../?之前 我只是把它們省略了,因為我認為系統只是按照慣例找到src並進行測試。

當我運行“ karma init”時,我得到:

readline.js:529
this.line = this.line.slice(this.cursor);
                   ^
  TypeError: Cannot read property 'slice' of undefined

當我運行“ testem”時,我得到:

TEST'EM 'SCRIPTS!
Open the URL below in a browser to connect.
http://localhost:7357/aN;0faN;NaNf

...然后項目的'../tests/index.html'加載到瀏覽器中,但無法“查找”任何資產文件(css,js),因此無法正確執行或呈現任何文件。 我只看到模板表達式({{content-for'head'}}等)。

當我運行“ ember test”時,我得到:

Building...BuildingBuilding.Building..Building...Built project successfully.

1..0
# tests 0
# pass  0
# fail  0

# ok
No tests were run, please check whether any errors occurred in the page (ember test --server) and ensure that you have a test launcher (e.g. PhantomJS) enabled.

當我運行“ ember test --server”時,我得到:

在瀏覽器中加載了帶有測試報告的測試index.html。 當我取消選中“隱藏通過的測試”時,報告顯示“ 29通過,28失敗”。 它有11個部分,其中特定測試可能存在3個問題,例如“無法加載”,“失敗”,“無法找到模塊”,“試圖注冊未知工廠”或“去世”。

有了這個,我顯然正在運行testem而不是業力,因此也可以在使testem工作並稍后確定業力方面進行工作。 如果有更多示例和遷移故障排除文檔,我可能有系統地解決其中一些問題。

節點升級后,我最近遇到“未運行測試,...”問題。 我用以下方法修復了它:

npm install -g phantomjs

這也提供了一些其他選項:

https://github.com/ember-cli/ember-cli/issues/3969

我在通過MSys2運行的MS Windows上Cannot read property 'slice' of undefined錯誤的Cannot read property 'slice' of undefined 我已經通過在普通cmd提示符下使用karma init解決了它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM