Posts

Showing posts with the label mocha

Mocha tests are ignored when used within repetitive stream callbacks

Image
Clash Royale CLAN TAG #URR8PPP Mocha tests are ignored when used within repetitive stream callbacks My task is to test some js function against big test vector corpus (10M+), also requirement to test in browser forced me to stream testvectors from local webserver, rather than synchronously read from file record by record. So, I'm obtaining (one per line ascii) test vectors this way: const http = require('http'); const readline = require('readline'); FetchTestVectors = function(filename, recordCb) { const url = "http://localhost:8080/" + filename; http.get(url) .on('response', function(response) { readline.createInterface({ input: response }) .on('line', function(line) { //recordCb(line.split(':')); recordCb(line); }) }); } And when trying to test it, inner describe-it block becomes ignored (all callbacks). However, I can see...

how to separate files for mocha-webpack

Image
Clash Royale CLAN TAG #URR8PPP how to separate files for mocha-webpack What's happening is that when I run my tests, my coverage only shows bundle.js which isn't that helpful. bundle.js I have the following webpack file setup and wanted to know what I should change to make it so that each file is covered individually webpack.config-test.js var nodeExternals = require("webpack-node-externals") const path = require("path") module.exports = { context: path.resolve(__dirname), resolve: { extensions: [".js"], alias: { "@": path.join(__dirname, "../../src/server"), } }, output: { path: "./", filename: "[name].js", }, target: "node", // webpack should compile node compatible code externals: [nodeExternals()], // in order to ignore all modules in node_modules folder } running the command via npm: nyc mocha-webpack --webpack-...