UNPKG

ianalyzer-test-app

Version:

A versatile code analysis tool for JavaScript, HTML, CSS, Angular, React, Vue, and ES6. iAnalyzer ensures code quality through linting, integrates with Sonar for in-depth analysis, performs npm package security checks, assesses performance, and enhances a

33 lines (28 loc) 1.02 kB
let report, childProcess; describe('Report Config Test', () => { beforeEach(() => { jest.clearAllMocks() jest.resetModules() report = () => require('../bin/report-config') childProcess = require('child_process'); jest.mock('child_process'); }) test('should generate report successfully', () => { process.argv[2] = null; childProcess.exec.mockImplementationOnce((execCommand, callback) => { callback(null); }); expect(report()).toBeUndefined(); }); test('should not generate report for invalid format', () => { process.argv[2] = 'xyz'; expect(report()).toBeUndefined(); }); test('should throw error for generate report', () => { process.argv[2] = 'json'; childProcess.exec.mockImplementationOnce((execCommand, callback) => { callback(new Error(), 'data', 'getter'); }); expect(() => report()).toThrow(); }); });