如何从命令行在Node.js上运行Jasmine测试 [英] How to run Jasmine tests on Node.js from command line

查看:102
本文介绍了如何从命令行在Node.js上运行Jasmine测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从命令行在Node.js上运行Jasmine测试?我已经通过npm安装了jasmine-node并编写了一些测试。我想在 spec 目录中运行测试并在终端中获得结果,这可能吗?

How do I run Jasmine tests on Node.js from command line? I have installed jasmine-node via npm and written some tests. I want to run tests inside the spec directory and get results in the terminal, is this possible?

推荐答案

编辑

由于软件包没有维护,这似乎不再是当前的最佳答案。请看下面的答案

It seems this is no longer the current best answer as the package is unmaintained. Please see the answer below

你可以这样做

从您的测试目录

sudo npm install jasmine-node

这将jasmine安装到../ node_modules / jasmine-node

This installs jasmine into ../node_modules/jasmine-node

然后

../node_modules/jasmine-node/bin/jasmine-node --verbose --junitreport --noColor spec

来自我的演示这是

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

这篇关于如何从命令行在Node.js上运行Jasmine测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆