Pao*_*aJ. 46 node.js jasmine jasmine-node
如何从命令行在Node.js上运行Jasmine测试?我已经通过npm安装了jasmine-node并编写了一些测试.我想在spec
目录中运行测试并在终端中获得结果,这可能吗?
use*_*141 91
这应该可以让你快速前进:
接下来安装Jasmine.打开命令提示符并运行:
npm install -g jasmine
接下来,cd到任何目录并设置一个示例'project':
jasmine init
jasmine examples
现在运行您的单元测试:
jasmine
如果你的jasmine.json文件在spec/support/jasmine.json之外的其他地方,只需运行:
jasmine JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.json
有关详情,请参阅:
Kee*_*yOn 23
编辑
似乎这不再是目前最好的答案,因为包没有维护.请参阅下面的答案
你可以这样做
从您的测试目录
sudo npm install jasmine-node
Run Code Online (Sandbox Code Playgroud)
这会将jasmine安装到../node_modules/jasmine-node中
然后
../node_modules/jasmine-node/bin/jasmine-node --verbose --junitreport --noColor spec
Run Code Online (Sandbox Code Playgroud)
从我的演示中做到这一点
Player - 5 ms
should be able to play a Song - 2 ms
when song has been paused - 1 ms
should indicate that the song is currently paused - 0 ms
should be possible to resume - 0 ms
tells the current song if the user has made it a favorite - 1 ms
#resume - 0 ms
should throw an exception if song is already playing - 0 ms
Player - 5 ms
should be able to play a Song - 2 ms
when song has been paused - 1 ms
should indicate that the song is currently paused - 0 ms
should be possible to resume - 0 ms
tells the current song if the user has made it a favorite - 1 ms
#resume - 0 ms
should throw an exception if song is already playing - 0 ms
Finished in 0.01 seconds
5 tests, 8 assertions, 0 failures, 0 skipped
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
60244 次 |
最近记录: |