node.js - Writing unit tests with jest for javascript minifier -
i'm new writing unit tests. need testing javascript minifier. i'm using jest test.
jsminifier:
const compressor = require('node-minify'); const dirsearch = require('directory-search'); const scrapeconfig = require('../scraper.config.js'); function jsoptimizer() { dirsearch(scrapeconfig.directory, '.js', (err, files) => { files.foreach(file => { compressor .minify({ compressor: 'uglifyjs', input: file, output: file, }) .catch(error => console.log(error)); }); }); } module.exports = jsoptimizer;
how go testing 100% conceptual coverage? if can provide example, appreciated.
so far have code(incomplete). trying load file variable , make sure minified file equal or less unminified code.
const dirsearch = require('directory-search'); const fs = require('fs'); const scrapeconfig = require('../scraper.config.js'); const jsoptimizer = require('../src/jsoptimizer.js'); test('throws error if minified code greater unminified code', () => { dirsearch(scrapeconfig.directory, '.js', (err, files) => { files.foreach(file => { }); if (err) throw err; console.log(files); }); jsoptimizer(); });
Comments
Post a Comment