mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-10 22:36:01 +00:00
Use mockery in tests to setup the realm module path(#727)
* Use mockery to set up the realm module path * Use the right path * Add mockery to devDependencies * Remove unnecessary symbolic link
This commit is contained in:
parent
8eb639678e
commit
d7c44fa7e9
@ -66,6 +66,7 @@
|
||||
"eslint-plugin-jasmine": "^2.1.0",
|
||||
"eslint-plugin-react": "^6.7.0",
|
||||
"jsdoc": "^3.4.0",
|
||||
"mockery": "^2.0.0",
|
||||
"semver": "^5.1.0"
|
||||
},
|
||||
"rnpm": {
|
||||
|
@ -29,7 +29,7 @@ function createNotificationTest(config, getObservable, addListener, removeListen
|
||||
return new Promise((resolve, reject) => {
|
||||
let realm = new Realm(config);
|
||||
let observable = getObservable(realm);
|
||||
let worker = new Worker(__dirname + '/worker-tests-script.js', [require.resolve('realm')]);
|
||||
let worker = new Worker(__dirname + '/worker-tests-script.js', [REALM_MODULE_PATH]);
|
||||
|
||||
// Test will fail if it does not receive a change event within a second.
|
||||
let timer = setTimeout(() => {
|
||||
|
@ -15,7 +15,6 @@
|
||||
"scripts": {
|
||||
"test": "jasmine spec/unit_tests.js spec/sync_tests.js",
|
||||
"test-nosync": "jasmine spec/unit_tests.js",
|
||||
"test-sync-integration": "jasmine spec/sync_integration_tests.js",
|
||||
"postinstall": "rm -f node_modules/realm && ln -s ../.. node_modules/realm"
|
||||
"test-sync-integration": "jasmine spec/sync_integration_tests.js"
|
||||
}
|
||||
}
|
||||
|
16
tests/spec/helpers/mock_realm.js
Normal file
16
tests/spec/helpers/mock_realm.js
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const mockery = require('mockery');
|
||||
|
||||
module.exports = function(realmModulePath) {
|
||||
if (typeof REALM_MODULE_PATH !== 'undefined')
|
||||
return;
|
||||
|
||||
global.REALM_MODULE_PATH = realmModulePath;
|
||||
|
||||
mockery.enable({
|
||||
warnOnReplace: false,
|
||||
warnOnUnregistered: false
|
||||
});
|
||||
mockery.registerSubstitute('realm', REALM_MODULE_PATH);
|
||||
}
|
4
tests/spec/helpers/setup-module-path.js
Normal file
4
tests/spec/helpers/setup-module-path.js
Normal file
@ -0,0 +1,4 @@
|
||||
const mock_helper = require('./mock_realm')
|
||||
const path = require('path');
|
||||
|
||||
mock_helper(path.resolve(__dirname, '../../..'))
|
Loading…
x
Reference in New Issue
Block a user