Hi there, I am a software developer and I like solving problems.
leonardomaier / jest-fs Goto Github PK
View Code? Open in Web Editor NEWfs module mock for jest unit testing
Home Page: https://www.npmjs.com/package/jest-fs
fs module mock for jest unit testing
Home Page: https://www.npmjs.com/package/jest-fs
Hi there, I am a software developer and I like solving problems.
We need to implement the mocked functionality of fs.renameSync(oldPath, newPath) and add a test case.
We need to implement the mocked functionality of fs.cpSync(src, dest[, options]) and add a test case.
We need to implement the mocked functionality of fs.writeSync(fd, buffer[, offset[, length[, position]]]) and add a test case.
We need to implement the mocked functionality of fs.closeSync(fd) and add a test case.
We need to implement the mocked functionality of fs.ftruncateSync(fd[, len]) and add a test case.
We need to implement the mocked functionality of fs.lchownSync(path, uid, gid) and add a test case.
We need to implement the mocked functionality of fs.readvSync(fd, buffers[, position]) and add a test case.
We need to implement the mocked functionality of fs.fdatasyncSync(fd) and add a test case.
We need to implement the mocked functionality of fs.readSync(fd, buffer[, options]) and add a test case.
We need to implement the mocked functionality of fs.fchownSync(fd, uid, gid) and add a test case.
We need to implement the mocked functionality of fs.copyFileSync and add a test case.
OBS: no need to implement the method options { mode: integer } at first.
We need to implement the mocked functionality of fs.openSync(path[, flags[, mode]]) and add a test case.
We need to implement the mocked functionality of fs.readdirSync(path[, options]) and add a test case.
We need to implement the mocked functionality of fs.lutimesSync(path, atime, mtime) and add a test case.
We need to implement the mocked functionality of fs.mkdirSync
and add a test case.
OBS: no need to implement the method options { recursive: boolean, mode: string }
We need to implement the mocked functionality of fs.chmodSync(path, mode) and add a test case.
We need to implement the mocked functionality of fs.opendirSync(path[, options]) and add a test case.
We need to implement the mocked functionality of fs.readlinkSync(path[, options]) and add a test case.
fs.writeFileSync = (file, content) => {
const dir = path.dirname(file);
if (!filesystem[dir]) {
filesystem[dir] = [];
}
filesystem[dir].push({
name: path.basename(file),
content,
});
};
fs.readFileSync = (file) => {
const files = ls(file);
const filename = path.basename(file);
const foundFile = files.find((currentFile) => currentFile.name === filename);
return foundFile.content;
};
If you write second time to same file with another content you wil not get this content. You'll get old content.
Use map instead of array
We need to implement the mocked functionality of fs.fstatSync(fd[, options]) and add a test case.
We need to implement the mocked functionality of fs.fchmodSync(fd, mode) and add a test case.
We need to implement the mocked functionality of fs.futimesSync(fd, atime, mtime) and add a test case.
We need to implement the mocked functionality of fs.rmdirSync(path[, options]) and add a test case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.