add support for the jest runner’s node environment

This commit is contained in:
Yavor Georgiev 2016-08-10 15:50:37 +02:00
parent 1a98077794
commit fb7911e3fa
4 changed files with 24 additions and 2 deletions

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

@ -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

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');
});
});