Skip to content

franjmr/jest_fs_node_module_mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jest_fs_node_module_mock

Mocking fs node-module with Jest

Mocking File System Node module

This project contains some examples of unit testing with Jest framework and Typescript that ensure the correct functionality of a class that uses the fs node module.

Mock specific module functions:

  • readFile
  • readFileSync
  • writeFileSync

The purpose of these examples is to show:

  • How we can falsify the writing and reading files.
  • Avoid contamination of the test context.
  • Avoid having physical files for tests.
  • Be able to alter the content of the files programmatically.
  • Spy on functionality.
  • Mock functions.

Install

npm install

Execute Test

npm run test

About

Mocking fs node-module with Jest

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published