realm-js/tests/index.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-04-19 08:38:46 +00:00
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////
/* eslint-env es6, node */
/* eslint-disable no-console */
2016-04-14 19:39:17 +00:00
'use strict';
const mockery = require('mockery');
function runTests() {
const RealmTests = require('./js');
const testNames = RealmTests.getTestNames();
let passed = true;
2016-04-14 19:39:17 +00:00
for (let suiteName in testNames) {
console.log('Starting ' + suiteName);
for (let testName of testNames[suiteName]) {
RealmTests.runTest(suiteName, 'beforeEach');
try {
RealmTests.runTest(suiteName, testName);
console.log('+ ' + testName);
}
catch (e) {
console.warn('- ' + testName);
console.error(e.message, e.stack);
passed = false;
2016-04-14 19:39:17 +00:00
}
finally {
RealmTests.runTest(suiteName, 'afterEach');
}
}
}
return passed;
2016-04-14 19:39:17 +00:00
}
if (require.main == module) {
mockery.enable();
mockery.warnOnUnregistered(false);
mockery.registerMock('realm', require('..'));
if (!runTests()) {
process.exit(1);
}
2016-04-14 19:39:17 +00:00
}