Skip to content

Commit

Permalink
maybe fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Mar 29, 2020
1 parent 8855c28 commit 8dd5817
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions e2e/__tests__/toMatchInlineSnapshot.test.ts
Expand Up @@ -256,6 +256,7 @@ test('handles mocking native modules prettier relies on', () => {
const test = `
jest.mock('path', () => ({}));
jest.mock('fs', () => ({}));
jest.mock('graceful-fs', () => ({}));
test('inline snapshots', () => {
expect({}).toMatchInlineSnapshot();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/init/__tests__/init.test.js
Expand Up @@ -20,7 +20,7 @@ jest.mock('../../../../jest-config/build/getCacheDirectory', () => () =>
'/tmp/jest',
);
jest.mock('path', () => ({...jest.requireActual('path'), sep: '/'}));
jest.mock('fs', () => ({
jest.mock('graceful-fs', () => ({
...jest.requireActual('fs'),
writeFileSync: jest.fn(),
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-config/src/__tests__/normalize.test.js
Expand Up @@ -19,7 +19,7 @@ const DEFAULT_CSS_PATTERN = '^.+\\.(css)$';
jest
.mock('jest-resolve')
.mock('path', () => jest.requireActual('path').posix)
.mock('fs', () => {
.mock('graceful-fs', () => {
const realFs = jest.requireActual('fs');

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-core/src/__tests__/SearchSource.test.ts
Expand Up @@ -15,7 +15,7 @@ import SearchSource, {SearchResult} from '../SearchSource';

jest.setTimeout(15000);

jest.mock('fs', () => {
jest.mock('graceful-fs', () => {
const realFs = jest.requireActual('fs');

return {
Expand Down
1 change: 0 additions & 1 deletion packages/jest-haste-map/src/__tests__/index.test.js
Expand Up @@ -104,7 +104,6 @@ jest.mock('graceful-fs', () => ({
mockFs[path] = data;
}),
}));
jest.mock('fs', () => require('graceful-fs'));

const cacheFilePath = '/cache-file';
const object = data => Object.assign(Object.create(null), data);
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-haste-map/src/crawlers/__tests__/node.test.js
Expand Up @@ -33,7 +33,7 @@ jest.mock('child_process', () => ({

let mockHasReaddirWithFileTypesSupport = false;

jest.mock('fs', () => {
jest.mock('graceful-fs', () => {
let mtime = 32;
const size = 42;
const stat = (path, callback) => {
Expand Down Expand Up @@ -384,7 +384,7 @@ describe('node crawler', () => {
describe('readdir withFileTypes support', () => {
it('calls lstat for directories and symlinks if readdir withFileTypes is not supported', () => {
nodeCrawl = require('../node');
const fs = require('fs');
const fs = require('graceful-fs');

const files = new Map();
return nodeCrawl({
Expand Down Expand Up @@ -416,7 +416,7 @@ describe('node crawler', () => {
it('avoids calling lstat for directories and symlinks if readdir withFileTypes is supported', () => {
mockHasReaddirWithFileTypesSupport = true;
nodeCrawl = require('../node');
const fs = require('fs');
const fs = require('graceful-fs');

const files = new Map();
return nodeCrawl({
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-reporters/src/__tests__/coverage_worker.test.js
Expand Up @@ -7,7 +7,7 @@

'use strict';

jest.mock('fs').mock('../generateEmptyCoverage');
jest.mock('graceful-fs').mock('../generateEmptyCoverage');

const globalConfig = {collectCoverage: true};
const config = {};
Expand All @@ -20,7 +20,7 @@ let worker;
beforeEach(() => {
jest.resetModules();

fs = require('fs');
fs = require('graceful-fs');
generateEmptyCoverage = require('../generateEmptyCoverage').default;
worker = require('../coverage_worker').worker;
});
Expand Down
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

jest.mock('fs', () => ({
jest.mock('graceful-fs', () => ({
...jest.genMockFromModule<typeof import('fs')>('fs'),
existsSync: jest.fn().mockReturnValue(true),
readdirSync: jest.fn().mockReturnValue([]),
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/__tests__/utils.test.ts
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

jest.mock('fs', () => ({
jest.mock('graceful-fs', () => ({
...jest.genMockFromModule<typeof import('fs')>('fs'),
existsSync: jest.fn().mockReturnValue(true),
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-source-map/src/__tests__/getCallsite.test.ts
Expand Up @@ -10,7 +10,7 @@ import SourceMap from 'source-map';
import getCallsite from '../getCallsite';

// Node 10.5.x compatibility
jest.mock('fs', () => ({
jest.mock('graceful-fs', () => ({
...jest.genMockFromModule<typeof import('fs')>('fs'),
ReadStream: jest.requireActual('fs').ReadStream,
WriteStream: jest.requireActual('fs').WriteStream,
Expand Down
Expand Up @@ -9,7 +9,7 @@ import * as path from 'path';
import * as fs from 'graceful-fs';
import TestSequencer from '../index';

jest.mock('fs', () => ({
jest.mock('graceful-fs', () => ({
...jest.genMockFromModule('fs'),
existsSync: jest.fn(() => true),
readFileSync: jest.fn(() => '{}'),
Expand Down
Expand Up @@ -10,7 +10,7 @@ import {wrap} from 'jest-snapshot-serializer-raw';
import {makeGlobalConfig, makeProjectConfig} from '../../../../TestUtils';

jest
.mock('fs', () =>
.mock('graceful-fs', () =>
// Node 10.5.x compatibility
({
...jest.genMockFromModule('fs'),
Expand Down

0 comments on commit 8dd5817

Please sign in to comment.