|
8 | 8 |
|
9 | 9 | 'use strict';
|
10 | 10 |
|
11 |
| -const slash = require('slash'); |
12 |
| - |
13 | 11 | jest
|
14 | 12 | .mock('fs', () =>
|
15 | 13 | // Node 10.5.x compatibility
|
16 | 14 | Object.assign({}, jest.genMockFromModule('fs'), {
|
17 | 15 | ReadStream: jest.requireActual('fs').ReadStream,
|
18 | 16 | WriteStream: jest.requireActual('fs').WriteStream,
|
19 | 17 | 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]; |
23 | 20 | }
|
24 | 21 |
|
25 |
| - throw new Error(`Cannot read path '${normalizedPath}'.`); |
| 22 | + throw new Error(`Cannot read path '${path}'.`); |
26 | 23 | }),
|
27 | 24 | statSync: path => ({
|
28 | 25 | isFile: () => !!mockFs[path],
|
|
39 | 36 | util.createDirectory = jest.fn();
|
40 | 37 | return util;
|
41 | 38 | })
|
42 |
| - .mock('vm'); |
| 39 | + .mock('vm') |
| 40 | + .mock('path', () => jest.requireActual('path').posix); |
43 | 41 |
|
44 | 42 | jest.mock(
|
45 | 43 | 'test_preprocessor',
|
@@ -138,8 +136,7 @@ let writeFileAtomic;
|
138 | 136 |
|
139 | 137 | jest.mock('write-file-atomic', () => ({
|
140 | 138 | sync: jest.fn().mockImplementation((filePath, data) => {
|
141 |
| - const normalizedPath = require('slash')(filePath); |
142 |
| - mockFs[normalizedPath] = data; |
| 139 | + mockFs[filePath] = data; |
143 | 140 | }),
|
144 | 141 | }));
|
145 | 142 |
|
@@ -167,18 +164,15 @@ describe('ScriptTransformer', () => {
|
167 | 164 | fs = require('graceful-fs');
|
168 | 165 | fs.readFileSync = jest.fn((path, options) => {
|
169 | 166 | 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]; |
174 | 169 | }
|
175 | 170 |
|
176 |
| - throw new Error(`Cannot read path '${normalizedPath}'.`); |
| 171 | + throw new Error(`Cannot read path '${path}'.`); |
177 | 172 | });
|
178 | 173 | fs.writeFileSync = jest.fn((path, data, options) => {
|
179 | 174 | expect(options).toBe('utf8');
|
180 |
| - const normalizedPath = slash(path); |
181 |
| - mockFs[normalizedPath] = data; |
| 175 | + mockFs[path] = data; |
182 | 176 | });
|
183 | 177 |
|
184 | 178 | fs.unlinkSync = jest.fn();
|
|
0 commit comments