uzay95
uzay95

Reputation: 16642

can mocha tests load reuqirements once?

I think every spec files first load by mocha and mocha runs them at least describe part if "it"s wasn't selected with "only".

// Lines before first "it" will run for every spec files 
// even if I don't mark them with ".only" word
var db = require("../../node/server/db"),
should = require('should')
...;

describe("main describe...", function () {
    var user = {},
        apiRootUrl = "http://127.0.0.1:3000";
        user.nameSurname = "Cem Topkaya";

    kullanici = schema.AJV.validate(schema_name, user);

    describe("child describe", function () {
        it(....)
        it.only(....)
        it(....)
    }
}

I want to run only one spec file not others. Is there any way to prevent this?

Upvotes: 0

Views: 45

Answers (1)

Louis
Louis

Reputation: 151541

If you give to Mocha the full path of your test file, it will just load that file and no other file:

$ mocha path/to/test.js

Upvotes: 1

Related Questions