Why does running `jasmine` after `jasmine init` and `jasmine examples` do nothing?

别说谁变了你拦得住时间么 提交于 2019-12-08 15:41:01

问题


I have globally installed jasmine by running npm install jasmine -g.

Running jasmine -v gives me

jasmine v2.5.0
jasmine-core v2.5.0

I have then, as per the docs, run

jasmine init
jasmine examples

This created the expected /spec directory and the spec/support/jasmine.json file.

I am under the impression that if I now run jasmine I should see some test output in the console. Instead it simply thinks about it for a second and then does nothing.

I'm running node v4.5.0 on a Windows 7 machine in a Git Bash terminal. I've tried running it from the Windows cmd prompt as well but that doesn't work either.


回答1:


well jasmine does run, but it doesn't report anything when you run jasmine alone. (you can confirm that by putting console.log inside describe functions and see that indeed it will log.)

download the latest release, it will have an html file that you can run which will do all the work for you.

https://github.com/jasmine/jasmine/releases

basically running jasmine requires a boot.js file for configurations. a jasmine-html.js file for the html reporter. you can figure out everything yourself by running the SpecRunner.html.

my personal preference is to use protractor and have the reporter configured in the protractor.config file.

if you want to run jasmine and have it run, you need to add your own boot.js and reporter, and loading them first thing before the spec in the jasmine.json file.

{
  "spec_dir": "spec",
  "spec_files": [
    "boot.js",
    "**/*[sS]pec.js"
  ],
  "helpers": [
    "helpers/**/*.js"
  ],
  "stopSpecOnExpectationFailure": false,
  "random": false
}



回答2:


It's a bug in jasmine

https://github.com/jasmine/jasmine-npm/issues/90

Use version 2.4

npm install -g jasmine@~2.4


来源:https://stackoverflow.com/questions/39272688/why-does-running-jasmine-after-jasmine-init-and-jasmine-examples-do-nothin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!