Category "mocha.js"

TypeScript error TS2403: Subsequent variable declarations must have the same type

I seem to be running into some compile errors on my TypeScript project. The full error is: node_modules/@types/mocha/index.d.ts:2680:13 - error TS2403: Subsequ

How to use GLOBAL FIXTURES in mocha JS to prepare preconditions of all test

I have read the document of mocha but can't follow the instruction. Because I have an Express Class like that // ExpressServer.js const http = require('http');

How do I automatically check for '.only' calls accidentally left in Mocha specs?

I occasionally forget to remove .only calls from my Mocha specs before pushing spec changes. Doing so obviously affects test coverage, which requires addressing

Mocha: Hide console.log output from successful tests

My Problem I'm writing a test suite for a Node.js application using Mocha. The functions that I'm testing write their logs to console.log directly, without any

Sinon Spy / Stub for Function inside Function (Private Function)

I'm new Sinon. i'm unable to spy the private ajax function Actual code in library.js function ajax () { console.log("I'm a"); } function getJSON() {

Unit testing for Google Cloud Functions

I was trying to write unit testing for Google Cloud Functions referring to Google Cloud Platform unit testing docs but not able to understand how to mock when G

How do I pass Mocha multiple files by path on the command line?

I am amassing a list of test files which need to be run. I'd like to pass them into Mocha via the command line. My current command looks like this: {here}/no

NestJS Share e2e server between test suites

I'm using NestJS test module to mock the nest app and I want to share this app among various test suites. Here's my setup: test |_ helpers |_ testApp.ts

Mocha + Chai: Continue and try all assertions after failure for the test

I would like the test runner to continue testing the whole it test even after the assertion fails. const { assert } = require('chai'); describe('Test suite', (

Connection Not established in Mocha to MongoDB Atlas

When starting my application it connects to MongoDB Atlas as logged, however, when running mocha tests it does not even try to connect to the DB. here is my ser

For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves

I have this test of nodejs when testing I get a error of done function not declared. Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done

How do I reset Hardhat's mainnet fork between tests?

I'm writing unit tests in Hardhat using Hardhat's mainnet fork, however it seems that the results from one test are affecting future tests and causing my assert

Run mocha excluding paths

I have this (in gulpfile.js): var gulp = require("gulp"); var mocha = require("gulp-mocha"); gulp.task("test", function() { gulp .src(["./**/*_test

How to configure .mocharc.yml to choose exports-style interface?

How to configure .mocharc.yml to choose exports-style interface. It should be like this ___:_____

What's the right way to enable the node debugger with mocha's --debug-brk switch?

I have some debugger statements in my module under test and want to run mocha with --debug-brk set and hit my breakpoint so that I can inspect the state of my m

Cannot find module 'ts-node/register'

I want to use mocha to test my TypeScript/Angular2 project. I tried to use ts-node as described here: npm install -g ts-node but when running mocha --r

Trying ES6 style import gives 'Cannot use import statement outside a module'

I am trying to write a javascript test in intellij for which I need to import some dependancies and I want to use ES6 style import statements but getting error

parametrized tests with Mocha

How can I create parametrized tests with Mocha? Sample use case: I have 10 classes, that are 10 different implementations of the same interface. I want to run