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

推荐答案

编辑

这似乎不再是当前的最佳答案,因为包裹没有得到维护.请看下面的答案


你能做到的

从你的测试目录

sudo npm install jasmine-node

这把茉莉花装进/node_模块/jasmine node

然后

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

这是我的demo分之一

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相关问答推荐

如何使用jq将依赖项添加到package.json中

如何在.npmrc中添加 comments ?

Socket.io 未将用户加入给定房间

在 NodeJS 中使用 post 时出现错误 500TypeError: 无法解构 'req.body' 的属性 'name',因为它未定义

Amplify 部署的应用程序出现TypeError: handler is not a function错误,但它在本地运行

未捕获的错误: 只能用作 元素的子元素,永远不会直接呈现.请将您的 包裹在

ResponseError:键空间ks1不存在

如何从名字,中间名,姓氏中获取全名并在结果中搜索匹配?

来自 child_process.exec 的错误没有这样的设备或地址,管道有帮助.为什么?

我怎样才能让`git`失败而不是要求提供凭据

AJAX 和 Node JS:在我的服务器中接收空数据

在 gatsby 中安装软件包时不推荐使用的错误

类型中缺少属性,该类型是由类实现的接口

如何将`yarn.lock`与`package.json`同步?

Dart 语言比 JavaScript (Node.js) 有什么好处

如何在 MongoDB 上只收听 localhost

如何在 MongoDB 中查询引用的对象?

如何使用 cookie 创建 HTTP 客户端请求?

在 Node.js 中混合使用 JavaScript 和 TypeScript

我可以让 node --inspect 自动打开 Chrome