在 Grunt 中使用 Intern(譯)

佛出寺發表於2014-07-28

Intern 內建就支援 Grunt. 安裝完 Intern 後, 使用 grunt.loadTasks("path/to/intern/grunt") (Intern 1.0) 或者 grunt.loadNpmTasks('intern')(Intern 1.1+) 來載入 Grunt 任務到你的 Gruntfile 中.

在 intern-examples 倉庫裡, 有一個 Grunt Intern 任務的例子可以參考.

================================================================

Grunt support is built into Intern. Install Intern and load the Grunt task into your Gruntfile usinggrunt.loadTasks('path/to/intern/grunt'); (Intern 1.0) or grunt.loadNpmTasks('intern')(Intern 1.1+).

An example of the Grunt Intern task is available in the intern-examples repository.

Task Options 任務選項 Options available when running Intern using Grunt are the same as the options available when running Intern directly from the command-line, plus the following additional options:

Name Default Description browserstackUsername (none) The username for authentication with BrowserStack. browserstackAccessKey (none) The access key for authentication with BrowserStack. runType 'client' The execution mode in which Intern should be run. This may be either 'runner' for the automated test runner, or 'client' for the Node.js client. sauceAccessKey (none) The access key for authentication with Sauce Labs. sauceUsername (none) The username for authentication with Sauce Labs. testingbotKey (none) The user key for authentication with TestingBot. testingbotSecret (none) The secret key for authentication with TestingBot. Events

The current Grunt events are rudimentary, based on the output of the default console reporter, and do not provide much detail into the actual state of the test runner to Grunt tasks. Future versions of Intern are likely to improve to provide first-class event support, if sufficient demand exists for this feature.

Event Parameters Description intern.pass data - A string that contains the pass message. This event is emitted when a test passes. intern.fail data - A string that contains the failure message. This event is emitted when a test fails. Gruntfile example

grunt.initConfig({ intern: { someReleaseTarget: { options: { runType: 'runner', // defaults to 'client' config: 'tests/intern', reporters: [ 'console', 'lcov' ], suites: [ 'myPackage/tests/all' ] } }, anotherReleaseTarget: { /* ... */ } }});// Load the Intern taskgrunt.loadNpmTasks('intern');// Register a test task that uses Interngrunt.registerTask('test', [ 'intern' ]);// By default we just testgrunt.registerTask('default', [ 'test' ]); 源: https://github.com/theintern/intern/wiki/Using-Intern-with-Grunt

相關文章