diff --git a/packages/jest-util/src/__tests__/createProcessObject.test.ts b/packages/jest-util/src/__tests__/createProcessObject.test.ts index c1658f793983..1af70c531084 100644 --- a/packages/jest-util/src/__tests__/createProcessObject.test.ts +++ b/packages/jest-util/src/__tests__/createProcessObject.test.ts @@ -6,6 +6,7 @@ */ import {EventEmitter} from 'events'; +import * as domain from 'domain'; let createProcessObject; @@ -105,3 +106,10 @@ it('checks that process.env works as expected in Windows platforms', () => { expect(fake.hasOwnProperty('PROP_STRING')).toBe(false); expect(fake.hasOwnProperty('PROP_string')).toBe(false); }); + +test('allows retrieving the current domain', () => { + const aDomain = domain.create(); + process.domain = aDomain; + + expect(createProcessObject().domain).toEqual(aDomain); +}); diff --git a/packages/jest-util/src/createProcessObject.ts b/packages/jest-util/src/createProcessObject.ts index 53d18dd43cb5..e04f48a5a3b5 100644 --- a/packages/jest-util/src/createProcessObject.ts +++ b/packages/jest-util/src/createProcessObject.ts @@ -112,5 +112,11 @@ export default function() { newProcess.env = createProcessEnv(); newProcess.send = () => {}; + Object.defineProperty(newProcess, 'domain', { + get() { + return process.domain; + }, + }); + return newProcess; }