package
A mock module system for testing require extensions
npm install fake-module-systemGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
A mock module system for testing require extensions.
$ npm install --save-dev fake-module-systemimport System from 'fake-module-system';
const system = new System({
'./foo.js': 'bar' // a file named foo.js with content "bar"
});
// alternate method instead of setting up content in the constructor.
system.content['./foo.js'] = 'bar';
let module = system.load('./foo.js');
// A module is not actually evaled, or ran. It just stores the code and filename
assert(module.code === 'bar');
assert(module.file === './foo.js');
// You can add custom require extensions for testing (the whole point of this module).
// This unrealisticly simple one just adds "quz" at the end of every file.
Related:
MIT © James Talmage
Estimated unpacked size across 3 packages.
64.2 kB
Includes dependencies.