Skip to content

Commit c3c8e83

Browse files
committed
gah, windows :(
1 parent dadd03e commit c3c8e83

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

packages/jest-runtime/src/__tests__/script_transformer.test.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@
88

99
'use strict';
1010

11-
const slash = require('slash');
12-
1311
jest
1412
.mock('fs', () =>
1513
// Node 10.5.x compatibility
1614
Object.assign({}, jest.genMockFromModule('fs'), {
1715
ReadStream: jest.requireActual('fs').ReadStream,
1816
WriteStream: jest.requireActual('fs').WriteStream,
1917
readFileSync: jest.fn((path, options) => {
20-
const normalizedPath = require('slash')(path);
21-
if (mockFs[normalizedPath]) {
22-
return mockFs[normalizedPath];
18+
if (mockFs[path]) {
19+
return mockFs[path];
2320
}
2421

25-
throw new Error(`Cannot read path '${normalizedPath}'.`);
22+
throw new Error(`Cannot read path '${path}'.`);
2623
}),
2724
statSync: path => ({
2825
isFile: () => !!mockFs[path],
@@ -39,7 +36,8 @@ jest
3936
util.createDirectory = jest.fn();
4037
return util;
4138
})
42-
.mock('vm');
39+
.mock('vm')
40+
.mock('path', () => jest.requireActual('path').posix);
4341

4442
jest.mock(
4543
'test_preprocessor',
@@ -138,8 +136,7 @@ let writeFileAtomic;
138136

139137
jest.mock('write-file-atomic', () => ({
140138
sync: jest.fn().mockImplementation((filePath, data) => {
141-
const normalizedPath = require('slash')(filePath);
142-
mockFs[normalizedPath] = data;
139+
mockFs[filePath] = data;
143140
}),
144141
}));
145142

@@ -167,18 +164,15 @@ describe('ScriptTransformer', () => {
167164
fs = require('graceful-fs');
168165
fs.readFileSync = jest.fn((path, options) => {
169166
expect(options).toBe('utf8');
170-
const normalizedPath = slash(path);
171-
172-
if (mockFs[normalizedPath]) {
173-
return mockFs[normalizedPath];
167+
if (mockFs[path]) {
168+
return mockFs[path];
174169
}
175170

176-
throw new Error(`Cannot read path '${normalizedPath}'.`);
171+
throw new Error(`Cannot read path '${path}'.`);
177172
});
178173
fs.writeFileSync = jest.fn((path, data, options) => {
179174
expect(options).toBe('utf8');
180-
const normalizedPath = slash(path);
181-
mockFs[normalizedPath] = data;
175+
mockFs[path] = data;
182176
});
183177

184178
fs.unlinkSync = jest.fn();

0 commit comments

Comments
 (0)