diff --git a/lib/index.js b/lib/index.js index 441e03f5..870bda94 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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; diff --git a/scripts/test.sh b/scripts/test.sh index 4c0c9c5e..1389653e 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -162,7 +162,7 @@ case "$TARGET" in scripts/download-core.sh node src/node/build-node.sh $CONFIGURATION - for runner in ava mocha; do + for runner in ava mocha jest; do pushd "$SRCROOT/tests/test-runners/$runner" npm install npm test diff --git a/tests/test-runners/jest/package.json b/tests/test-runners/jest/package.json new file mode 100644 index 00000000..42391167 --- /dev/null +++ b/tests/test-runners/jest/package.json @@ -0,0 +1,15 @@ +{ + "scripts": { + "test": "jest" + }, + "devDependencies": { + "jest-cli": "^13.2.3" + }, + "jest": { + "testEnvironment": "node", + "unmockedModulePathPatterns": [ + "realm" + ], + "testRegex": "test.js" + } +} diff --git a/tests/test-runners/jest/test.js b/tests/test-runners/jest/test.js new file mode 100644 index 00000000..6b5d9043 --- /dev/null +++ b/tests/test-runners/jest/test.js @@ -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'); + }); +});