mockSignValidator is mock library of validator,
which can be used to simplify the test environment of validation.
-
global:
npm i -g @khgame/mock-sign-validator -
project:
npm i --save @khgame/mock-sign-validatoror
yarn add @khgame/mock-sign-validator
mockSignValidator [-P port] or
npx mockSignValidator [-P port]
the default port is 11601
For unit test, the mockSignValidator can be started as a child process. Therefore, it will listen to specific port (default:11601) to enable hence tests .
ex.
import {exec} from 'child_process';
import {forMs} from "kht";
describe(`validate owner_id`, async function () {
// ...
let validatorProcess;
before(async () => {
// ...
console.log("=> start mock");
validatorProcess = exec("npx mockSignValidator start -m", function (err) {
if(err) { console.log('child exit code (exec)', err.code); }
});
await forMs(1000);
console.log("=> start test");
// ...
});
after((done) => {
//...
validatorProcess.kill();
console.log("=> end login server mock");
// ...
done();
});
// it( ...
})