天天看點

"Karma-How It Works"Karma怎麼運作

翻譯位址:http://karma-runner.github.io/0.12/intro/how-it-works.html

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results for each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

Karma本質上是一個在各種浏覽器運作測試代碼的工具,各種浏覽器會運作和展示測試的結果例如通過還是不通過。

A browser can be captured either

  • manually, by visiting the URL where the Karma server is listening (typically 

    http://localhost:9876/

    ),
  • 通過手動通路Karma伺服器監聽的URL(通常是 http://localhost:9876/)
  • or automatically by letting Karma know which browsers to start when Karma is run (see browsers).
  • 或者當Karma運作時自動讓Karma識别那個浏覽器已經運作

Karma also watches all the files, specified within the configuration file, and whenever any file changes, it triggers the test run by sending a signal to the testing server to inform all of the captured browsers to run the test code again. Each browser then loads the source files inside an IFrame, executes the tests and reports the results back to the server.

Karma也監聽所有檔案,配置檔案中指定的,每當任何檔案更改時,它都會通過資訊觸發測試用例到測試伺服器上的浏覽器運作,每個浏覽器通過裡面的IFrame加載資源檔案,執行測試并傳回報告。

The server collects the results from all of the captured browsers and presents them to the developer.

伺服器收集從伺服器傳回的所有結果并将其回報給開發者。

This is only a very brief overview, as the internals of how Karma works aren't entirely necessary when using Karma.

這隻是簡短的描述,用Karma時,内部具體是怎麼操作的并不十分需要關心

However, if you are interested in learning more, Karma itself originates from a university thesis, which goes into detail about the design and implementation, and it is available to read right here.

但你如果想了解更多,可以通路下面連結。

繼續閱讀