mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(package) add mock-require, clear-module
This commit is contained in:
parent
2cd1bd9201
commit
196b72448d
2 changed files with 5 additions and 6 deletions
|
|
@ -13,6 +13,8 @@ const validatePath = `${dir}/server/validate`;
|
|||
const exitPath = `${dir}/server/exit`;
|
||||
|
||||
const validate = require(validatePath);
|
||||
const stub = require('mock-require');
|
||||
const clear = require('clear-module');
|
||||
|
||||
test('validate: root: bad', (t) => {
|
||||
const config = {
|
||||
|
|
@ -106,11 +108,7 @@ test('validate: editor: not valid', (t) => {
|
|||
});
|
||||
|
||||
function clean() {
|
||||
delete require.cache[require.resolve(validatePath)];
|
||||
delete require.cache[require.resolve(exitPath)];
|
||||
}
|
||||
|
||||
function stub(name, fn) {
|
||||
require.cache[require.resolve(name)].exports = fn;
|
||||
clear(validatePath);
|
||||
clear(exitPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue