は私が複数のテストファイルで実行する一般的なテストを持って、私はいくつかの研究を行なったし、これは私がファイルにテストを含むことが見出さ提案された解決策である:モカ/チェア - 走行テスト複数のファイルで
ディレクトリ構造:
|--test
|--common
|--common.js
|--common_functions.js
|--helpers.js
|--registration.js
common.js
var helpers = require("../../services/helpers");
var chai = require("chai");
var expect = require("chai").expect;
chai.should();
chai.use(require("chai-things"));
var testData = require("../../config/testData");
it('check if we are connected to local test db', function(done) {
helpers.checkTestDB(function(err, result) {
expect(err).to.equal(null);
result.should.equal('This is the test DB');
done();
});
});
common_functions.js
exports.importTest = function(name, path) {
describe(name, function() {
require(path);
});
}
helpers.js/registration.js
...
var common_functions = require('./common_functions');
...
describe("Common Tests Import", function(){
common_functions.importTest("checkDb",'./common/common');
});
問題は、私はそれの両方でそれを残す場合は、テストにのみ、の2つのファイルのいずれかで実行されていることをありますヘルパーを実行します。ヘルパーをコメントアウトすると、登録が実行されます。これは、それぞれの方法で実行できますか?
私は、テスト用のデータベースを使用するために各ファイルにenv変数を設定していますが、多くのことが起こっていて、何らかの形で変更する場合は、それぞれのファイルを別々に実行したいと思います。