How do you mock MySQL (without an ORM) in Node.js?
With sinon, you can put a mock or stub around an entire module. For example, suppose the mysql module has a function query: var mock; mock = sinon.mock(require(‘mysql’)) mock.expects(‘query’).with(queryString, queryParams).yields(null, rows); queryString, queryParams are the input you expect. rows is the output you expect. When your class under test now require mysql and calls the … Read more