Подтвердить что ты не робот

Как запустить тесты Jasmine на Node.js из командной строки

Как запустить тесты Jasmine на Node.js из командной строки? Я установил jasmine- node через npm и написал несколько тестов. Я хочу запустить тесты внутри каталога spec и получить результаты в терминале, возможно ли это?

4b9b3361

Ответ 1

ИЗМЕНИТЬ

Кажется, что это уже не лучший ответ, поскольку пакет не поддерживается. См. Ответ ниже


Вы можете сделать это

из тестового каталога

sudo npm install jasmine-node

Это устанавливает жасмин в. / node_modules/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

Ответ 2

Это поможет вам быстро:

  • установите Node.js(очевидно).
  • Затем установите 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

Подробнее см.: