From a7e2483428b2c5efbcf5f215087ad6404adde74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Fri, 11 Aug 2017 11:57:17 +0200 Subject: [PATCH] Made a node package that uses the shared tests to run in node --- scripts/test.sh | 25 +++++++++++++++---------- tests/node/package.json | 14 ++++++++++++++ tests/node/unit-tests.js | 11 +++++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 tests/node/package.json create mode 100644 tests/node/unit-tests.js diff --git a/scripts/test.sh b/scripts/test.sh index fb2bf8d2..7f4eaad0 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -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 diff --git a/tests/node/package.json b/tests/node/package.json new file mode 100644 index 00000000..24e0da3c --- /dev/null +++ b/tests/node/package.json @@ -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" + } +} diff --git a/tests/node/unit-tests.js b/tests/node/unit-tests.js new file mode 100644 index 00000000..d1c7983c --- /dev/null +++ b/tests/node/unit-tests.js @@ -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());