I’ve written a unit test for the following code and stubbed the browser methods (read: web-extension API) using Sinon (more specifically: sinon-chrome, a dated but still functioning library for my use case). The unit test: The tests fail due to both the stubbed methods returning undefined, but the Sinon docs state quite clearly that stub.resolves(value): Causes the stub to return
Tag: mocha.js
Mocha + TypeScript: Cannot use import statement outside a module
I was watching this video in order to learn how to add some simple tests to my Express routes but I am getting all kind of errors while executing a test. The error is: import * as chai from ‘chai’; ^^^^^^ SyntaxError: Cannot use import statement outside a module I have read some similar Stack Overflow questions and GitHub issues
eslint should be listed in the project’s dependencies, not devDependencies
Either I don’t understand dependencies vs. devDependencies in node 100% yet or eslint is just wrong here (not capable of analyzing this correctly): These are test dependencies, so why is it saying that they should be listed in dependencies? Additional note: We’re using Travis as our CI so I don’t know if it makes a difference for that at all
Chai expect: an array to contain an object with at least these properties and values
I’m trying to validate that an array of objects like this: contains at least one object with both { a: 1 } and { c: 3 }: I thought I could do this with chai-things, but I don’t know all the properties of the object to be able to use and contain.a.thing.with.property doesn’t work with multiple properties :/ What’s the
Change default timeout for mocha
If we have a unit test file my-spec.js and running with mocha: The default timeout will be 2000 ms. It can be overwritten for partial test with a command line parameter: Is it possible to change the default timeout globally for all tests? i.e. the default timeout value will be different from 2000 ms when you call: Answer By default