Merge pull request #561 from realm/yg/testrunner-tests

Make realm-js usable in some major test runners
This commit is contained in:
Yavor Georgiev 2016-08-11 11:33:38 +02:00 committed by GitHub
commit b88d8a6359
10 changed files with 70 additions and 1 deletions

View File

@ -5,3 +5,5 @@
build/
node_modules/
vendor/
/tests/test-runners/

View File

@ -29,7 +29,7 @@ if (typeof Realm != 'undefined') {
// The userAgent will be defined when running in a browser (such as Chrome debugging mode).
realmConstructor = require('./browser').default; // (exported as ES6 module)
// eslint-disable-next-line
} else if (typeof process == 'object' && ('' + process) == '[object process]') {
} else if (typeof process == 'object' && (('' + process) == '[object process]' || typeof jest == 'object')) {
// Prevent React Native packager from seeing this module.
var bindings = 'bindings';
realmConstructor = require(bindings)('realm').Realm;

View File

@ -157,6 +157,18 @@ case "$TARGET" in
node "$SRCROOT/tests"
;;
"test-runners")
npm install
scripts/download-core.sh node
src/node/build-node.sh $CONFIGURATION
for runner in ava mocha jest; do
pushd "$SRCROOT/tests/test-runners/$runner"
npm install
npm test
popd
done
;;
"object-store")
pushd src/object-store
cmake -DCMAKE_BUILD_TYPE=$CONFIGURATION .

View File

@ -0,0 +1,8 @@
{
"scripts": {
"test": "ava"
},
"devDependencies": {
"ava": "^0.16.0"
}
}

View File

@ -0,0 +1,7 @@
import test from 'ava';
test('can require Realm', t => {
var realm = require('realm');
t.is('function', typeof realm);
t.is('Realm', realm.name);
});

View File

@ -0,0 +1,15 @@
{
"scripts": {
"test": "jest"
},
"devDependencies": {
"jest-cli": "^13.2.3"
},
"jest": {
"testEnvironment": "node",
"unmockedModulePathPatterns": [
"realm"
],
"testRegex": "test.js"
}
}

View File

@ -0,0 +1,7 @@
describe('Realm', function() {
it('should be requirable', function() {
var realm = require('realm');
expect(typeof realm).toBe('function');
expect(realm.name).toBe('Realm');
});
});

View File

@ -0,0 +1,8 @@
{
"scripts": {
"test": "mocha"
},
"devDependencies": {
"mocha": "^3.0.2"
}
}

View File

@ -0,0 +1,9 @@
var assert = require('assert');
describe('Realm', function() {
it('should be requirable', function() {
var realm = require('realm');
assert.equal(typeof realm, 'function');
assert.equal(realm.name, 'Realm');
});
});

1
tests/test-runners/node_modules/realm generated vendored Symbolic link
View File

@ -0,0 +1 @@
../../..