1

Как я могу настроить случайную опцию, используя grunt-contrib-jasmine? Я могу сделать это напрямую с помощью командной строки jasmine, но, выполнив задачу jasmine с помощью grunt-cli, я не нашел случайной опции. Тогда выходные данные командной строки всегда показывают случайные выходные данные спецификаций.

Пример обновлен:

Ниже json Жасмин:

{
  // Spec directory path relative to the current working dir when jasmine is executed.
  "spec_dir": "spec",

  // Array of filepaths (and globs) relative to spec_dir to include and exclude
  "spec_files": [
    "**/*[sS]pec.js"
  ],

  // Array of filepaths (and globs) relative to spec_dir to include before jasmine specs
  "helpers": [
    "helpers/**/*.js"
  ],

  // Stop execution of a spec after the first expectation failure in it
  stopSpecOnExpectationFailure: false,

  // This is the random option I need on gruntfile
  random: false
}

Ниже gruntfile JSON:

module.exports = function(grunt) {
    grunt.initConfig({
         pkg: grunt.file.readJSON('package.json')
        ,jasmine : {
             myapp  : {
                 src   : ['src/**/*.js']
                ,options : {
                     specs : 'spec/**/*{s,S}pec.js'
                }
            }
        }
    });
    ...

1 ответ1

0

Я нашел ответ на свой вопрос. По крайней мере, я проверил, и это сработало. В верхней части каждой описательной декларации вы можете настроить случайную опцию вашего Suit Test. Это может быть со следующим утверждением:

describe('My suite', function(){
   jasmine.getEnv().configure({random:false});

   // There are several tests here... 

   afterAll(function(){
      jasmine.getEnv().configure({random:true});
   });

   ...

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .