Node.js测试中的Mock文件系统详解

时间:2020-12-23 10:36:19
【文件属性】:
文件名称:Node.js测试中的Mock文件系统详解
文件大小:34KB
文件格式:PDF
更新时间:2020-12-23 10:36:19
c js mock Mock文件系统相关的工具包括:     Mock fs 模块的工具mock-fs 。     Mock require 模块的工具mock-require 。 安装 mock-fs和 mock-require 都是NPM软件包,在项目中可通过npm直接安装: npm install mock-fs mock-require --save Mock fs 模块 通过mock()方法可以创建多个文件的Mock并立即生效, 此后对fs的调用都会访问这些Mock文件。 调用mock.restore()可取消Mock并恢复fs。 var fs = require('fs'); var mock

网友评论