fix: removed mock-fs library
MODIFY
package.json
package.json
},
"devDependencies": {
"@types/jest": "^23.3.1",
- "@types/mock-fs": "^3.6.30",
"@types/supertest": "^2.0.4",
"husky": "^0.14.0",
"if-env": "^1.0.4",
"jest": "^23.5.0",
"lerna": "~3.3.0",
"lint-staged": "^7.2.2",
- "mock-fs": "^4.5.0",
"mock-req": "^0.2.0",
"rimraf": "^2.6.2",
"rxjs-compat": "^6.1.0",

MODIFY
packages/core/src/+internal/files/fileReader.helper.spec.ts
packages/core/src/+internal/files/fileReader.helper.spec.ts
-import * as mockFs from 'mock-fs';
+import * as fs from 'fs';
import { readFile } from './fileReader.helper';
describe('File reader', () => {
@@ -11,10 +11,12 @@ describe('File reader', () => {
it('#readFile returns error when not found', done => {
// given
- mockFs();
+ const expectedError = { code: 'ENOENT', message: 'ENOENT, no such file or directory' };
// when
+ const readFileStub = (_, callback) => callback(expectedError);
const subscription = readFile('test/url')('index.html');
+ spyOn(fs, 'readFile').and.callFake(readFileStub);
// then
subscription.subscribe(
@@ -32,26 +34,26 @@ describe('File reader', () => {
it('#readFile returns Buffer when found', done => {
// given
- mockFs({ 'test/url': { 'index.html': 'test' } });
+ const mockedData = 'test_data';
+ const mockedBuffer = new Buffer(mockedData);
// when
+ const readFileStub = (_, callback) => callback(undefined, mockedBuffer);
const subscription = readFile('test/url')('index.html');
+ spyOn(fs, 'readFile').and.callFake(readFileStub);
// then
subscription.subscribe(
data => {
expect(data).toBeDefined();
expect(Buffer.isBuffer(data)).toEqual(true);
- expect(data.toString()).toEqual('test');
+ expect(data.toString()).toEqual(mockedData);
done();
},
error => {
- fail(`Exceptions shouldn't be thrown`);
+ fail(`Exceptions shouldn't be thrown: ${error}`);
done();
}
);
});
-
- afterEach(() => mockFs.restore());
-
});

MODIFY
yarn.lock
yarn.lock
version "2.0.0"
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.0.tgz#5a7306e367c539b9f6543499de8dd519fac37a8b"
-"@types/mock-fs@^3.6.30":
- version "3.6.30"
- resolved "https://registry.yarnpkg.com/@types/mock-fs/-/mock-fs-3.6.30.tgz#4d812541e87b23577261a5aa95f704dd3d01e410"
- dependencies:
- "@types/node" "*"
-
"@types/node@*":
version "10.7.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.7.1.tgz#b704d7c259aa40ee052eec678758a68d07132a2e"
@@ -4022,10 +4016,6 @@ mixin-deep@^1.2.0:
dependencies:
minimist "0.0.8"
-mock-fs@^4.5.0:
- version "4.6.0"
- resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.6.0.tgz#d944ef4c3e03ceb4e8332b4b31b8ac254051c8ae"
-
mock-req@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/mock-req/-/mock-req-0.2.0.tgz#749446804d2c006169342ee7be6bba1cffd534c2"

fix: removed mock-fs library