How to run Jasmine tests on Node.js from command line

前端 未结 4 1656
梦毁少年i
梦毁少年i 2020-12-14 05:40

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 direc

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-14 06:12

    EDIT

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


    You can do this

    from your test directory

    sudo npm install jasmine-node
    

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

    then

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

    which from my demo does this

    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
    

提交回复
热议问题