From 45ca2f3e134ac99bdc415ffa6eed4419bbe62b41 Mon Sep 17 00:00:00 2001 From: Jason Palmer Date: Sat, 23 Jun 2018 12:56:56 -0400 Subject: [PATCH] Node 10.5.x compatibility on CI for tests --- .../jest-runtime/src/__tests__/script_transformer.test.js | 8 +++++++- packages/jest-util/src/__tests__/get_callsite.test.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/jest-runtime/src/__tests__/script_transformer.test.js b/packages/jest-runtime/src/__tests__/script_transformer.test.js index b8386affa691..a9227914c534 100644 --- a/packages/jest-runtime/src/__tests__/script_transformer.test.js +++ b/packages/jest-runtime/src/__tests__/script_transformer.test.js @@ -11,7 +11,13 @@ const slash = require('slash'); jest - .mock('fs') + .mock('fs', () => + // Node 10.5.x compatibility + Object.assign({}, jest.genMockFromModule('fs'), { + ReadStream: require.requireActual('fs').ReadStream, + WriteStream: require.requireActual('fs').WriteStream, + }), + ) .mock('graceful-fs') .mock('jest-haste-map', () => ({ getCacheFilePath: (cacheDir, baseDir, version) => cacheDir + baseDir, diff --git a/packages/jest-util/src/__tests__/get_callsite.test.js b/packages/jest-util/src/__tests__/get_callsite.test.js index c6f3237c126c..7166d7a3a61b 100644 --- a/packages/jest-util/src/__tests__/get_callsite.test.js +++ b/packages/jest-util/src/__tests__/get_callsite.test.js @@ -2,7 +2,13 @@ import fs from 'fs'; import SourceMap from 'source-map'; import getCallsite from '../get_callsite'; -jest.mock('fs'); +// Node 10.5.x compatibility +jest.mock('fs', () => + Object.assign({}, jest.genMockFromModule('fs'), { + ReadStream: require.requireActual('fs').ReadStream, + WriteStream: require.requireActual('fs').WriteStream, + }), +); describe('getCallsite', () => { test('without source map', () => {