Made a node package that uses the shared tests to run in node

This commit is contained in:
Kræn Hansen 2017-08-11 11:57:17 +02:00
parent cb4ef75f70
commit a7e2483428
3 changed files with 40 additions and 10 deletions

View File

@ -345,22 +345,27 @@ case "$TARGET" in
if [ "$(uname)" = 'Darwin' ]; then
download_server
start_server
npm_tests_cmd="npm run test"
npm install --build-from-source --realm_enable_sync
else
npm_tests_cmd="npm run test"
npm install --build-from-source
fi
# Change to a temp directory.
cd "$(mktemp -q -d -t realm.node.XXXXXX)"
test_temp_dir=$PWD # set it to be cleaned at exit
pushd "$SRCROOT/tests"
npm install
eval "$npm_tests_cmd"
pushd "$SRCROOT/tests/node"
if [ "$(uname)" = 'Darwin' ]; then
npm install --build-from-source --realm_enable_sync
else
npm install --build-from-source
fi
npm test
popd
stop_server
if [ "$(uname)" = 'Darwin' ]; then
stop_server
fi
;;
"electron")
if [ "$(uname)" = 'Darwin' ]; then
@ -392,7 +397,7 @@ case "$TARGET" in
# npm test -- --filter=GarbageCollectionTests
# npm test -- --filter=AsyncTests
npm test -- --process=main
# npm test -- --process=main
npm test -- --process=render
popd

14
tests/node/package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "realm-node-tests",
"private": true,
"description": "Test harness running the Realm JS tests in a node process.",
"main": "index.js",
"scripts": {
"test": "node ./unit-tests.js",
"test-sync-integration": "node ./sync-integration-tests.js"
},
"devDependencies": {
"realm": "../..",
"realm-tests": "../shared"
}
}

11
tests/node/unit-tests.js Normal file
View File

@ -0,0 +1,11 @@
"use strict";
const path = require("path");
const SPEC_PATH = require.resolve("realm-tests/spec/unit_tests.js");
const JASMINE_SPEC_PATH = path.resolve(__dirname, "node_modules", "realm-tests", "spec");
const JASMINE_CONFIG_PATH = require.resolve("realm-tests/spec/support/jasmine.json");
const jasmine = require("realm-tests/jasmine.js");
jasmine.loadConfigFile(JASMINE_CONFIG_PATH);
jasmine.execute([ SPEC_PATH ], jasmine.getFilterFromProcess());