Jasmine tests - node runs twice

My jasmine-node tests run twice.

I run those tests from the Grunt task, as well as from the Jasmine team. The result is the same, my tests are performed twice. My .json package:

{
  "name": "test",
  "version": "0.0.0",
  "dependencies": {
    "express": "4.x",
    "mongodb": "~2.0"
  },
  "devDependencies": {
    "grunt": "~0.4.5",
    "grunt-jasmine-node":"~0.3.1 "
  }
}

Here is my Gruntfile.js extract:

    grunt.initConfig({
    jasmine_node: {
      options: {
        forceExit: true,
        match: '.',
        matchall: true,
        extensions: 'js',
        specNameMatcher: 'spec'
      },
      all: ['test/']
    }
  });
  grunt.loadNpmTasks('grunt-jasmine-node');
  grunt.registerTask('jasmine', 'jasmine_node');

One of my test files:

describe("Configuration setup", function() {
    it("should load local configurations", function(next) {
        var config = require('../config')();
        expect(config.mode).toBe('local');
        next();
    });
    it("should load staging configurations", function(next) {
        var config = require('../config')('staging');
        expect(config.mode).toBe('staging');
        next();
    });
    it("should load production configurations", function(next) {
        var config = require('../config')('production');
        expect(config.mode).toBe('production');
        next();
    });
});

I have 2 test files for 4 statements

Here is my hint:

grunt jasmine
Running "jasmine_node:all" (jasmine_node) task
........

Finished in 1.781 seconds
8 tests, 8 assertions, 0 failures, 0 skipped

Do you have an idea?

+4
source share
1 answer

All loans 1.618 . He answered this question: runt jasmine-node tests run twice

This looks like an incorrect behavior. Quick fix is to set up jasmine_nodein Gruntfilethe following way:

jasmine_node: {
    options: {
        forceExit: true,
        host: 'http://localhost:' + port + '/',
        match: '.',
        matchall: false,
        extensions: 'js',
        specNameMatcher: '[sS]pec'
    },
    all: []
}

- all. grunt . - spec/ . spec, . , , .

+2

Source: https://habr.com/ru/post/1584770/


All Articles