Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('handles vision plugin registration failures', async flags => {
// cleanup
const visionRegister = Vision.plugin.register;
flags.onCleanup = function() {
Vision.plugin.register = visionRegister;
};
// setup
const PLUGIN_ERROR = 'plugin error';
Vision.plugin.register = async function() {
throw new Error(PLUGIN_ERROR);
};
const server = Hapi.server();
// exercise and validate
await expect(server.register(Docs)).to.reject(PLUGIN_ERROR);
});
flags.onCleanup = function() {
Vision.plugin.register = visionRegister;
};