mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 09:25:46 +00:00
fix: make promisify working by mocking the entire file-system
This commit is contained in:
parent
f646f9ceda
commit
1f39b5b904
@ -49,9 +49,11 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@strapi/pack-up": "4.15.5",
|
"@strapi/pack-up": "4.15.5",
|
||||||
|
"@strapi/plugin-upload": "4.15.5",
|
||||||
"@types/jest": "29.5.2",
|
"@types/jest": "29.5.2",
|
||||||
"eslint-config-custom": "4.15.5",
|
"eslint-config-custom": "4.15.5",
|
||||||
"tsconfig": "4.15.5"
|
"tsconfig": "4.15.5",
|
||||||
|
"memfs": "4.6.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <=20.x.x",
|
"node": ">=18.0.0 <=20.x.x",
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
|
/* eslint-disable import/first */
|
||||||
|
import { fs } from 'memfs';
|
||||||
|
|
||||||
|
jest.mock('fs', () => fs);
|
||||||
|
|
||||||
|
import fse from 'fs-extra';
|
||||||
|
|
||||||
import type { File } from '@strapi/plugin-upload';
|
import type { File } from '@strapi/plugin-upload';
|
||||||
|
|
||||||
import localProvider from '../index';
|
import localProvider from '../index';
|
||||||
|
|
||||||
jest.mock('fs', () => {
|
|
||||||
return {
|
|
||||||
writeFile: jest.fn((_path, _buffer, callback) => callback()),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
jest.mock('fs-extra', () => {
|
|
||||||
return {
|
|
||||||
pathExistsSync: jest.fn(() => true),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Local provider', () => {
|
describe('Local provider', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
globalThis.strapi = {};
|
globalThis.strapi = {};
|
||||||
globalThis.strapi.dirs = { static: { public: '' } };
|
globalThis.strapi.dirs = { static: { public: '' } };
|
||||||
|
|
||||||
|
fse.ensureDirSync('uploads');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
@ -9790,6 +9790,7 @@ __metadata:
|
|||||||
resolution: "@strapi/provider-upload-local@workspace:packages/providers/upload-local"
|
resolution: "@strapi/provider-upload-local@workspace:packages/providers/upload-local"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@strapi/pack-up": "npm:4.15.5"
|
"@strapi/pack-up": "npm:4.15.5"
|
||||||
|
"@strapi/plugin-upload": "npm:4.15.5"
|
||||||
"@strapi/utils": "npm:4.15.5"
|
"@strapi/utils": "npm:4.15.5"
|
||||||
"@types/jest": "npm:29.5.2"
|
"@types/jest": "npm:29.5.2"
|
||||||
eslint-config-custom: "npm:4.15.5"
|
eslint-config-custom: "npm:4.15.5"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user