8,475 questions
0
votes
1
answer
23
views
Any way to fold unit tests in VS Code so that the title of the unit test is displayed?
In VS Code (I use a few different folding extensions) I am trying to get some reasonable folding for unit tests, similar to methods, where titles are shown but code is folded. Currently using ...
0
votes
0
answers
28
views
Mocha doesn't rerun all tests after I update test files
I have my Mocha config file:
{
"diff": true,
"extension": ["js", "cjs", "mjs"],
"package": "./package.json",
"slow&...
0
votes
0
answers
34
views
Mock exported instances of private classes
I have a class "SomeService" which isn't exported. I export the instance which can be used to call functions on it. Basicly a singleton.
Here the example
export const someService = new ...
2
votes
0
answers
94
views
Electron + Mocha + WDIO unable to mock ipcMain calls
Update: Created Minimal reproducible example on GitHub.
I'm having an issue with mocking ipcMain in wdio + electron + mocha. I have a running electron app that I'm trying to e2e test, but I'm unable ...
0
votes
2
answers
59
views
Is there way to override mocha it function?
I am trying to integrate qase.io with cypress. However with Qase, I need to follow below pattern where I need to pass test function along with ID. For eg:
describe('My First Test', () => {
qase(1,...
0
votes
0
answers
24
views
WebdriverIO: can't access window attribute
I'm having trouble accessing the window attribute in WebdriverIO testing.
In the JavaScript code I create a new instance of OpenLayers:
import Map from 'ol/Map.js';
import View from 'ol/View.js';
...
1
vote
0
answers
52
views
Why are my tests failing for a WhatsAppbot using whatsapp-web.js? Potential issue with mocks
I have written a WhatsApp bot using whatsapp-web.js, and it works fine in production. However, when I try to run tests, they fail, and I suspect the issue lies with my mocks, but I am not entirely ...
-1
votes
1
answer
41
views
Mocha "TypeError: (0 , calc_1.addition) is not a function" when trying to test
I have a simple project structure:
I am trying to test "addition" function inside of the src/calculator.ts
export function addition(a: number, b: number): number {
return a + b;
}
Here'...
0
votes
0
answers
78
views
Mocha chai test cases are not completing due to on sinon stub
Am using a typical node express typescript project, where i have controller and service file, am trying to write simple testcase for controller file, its executes the test case but after that it's not ...
2
votes
0
answers
28
views
running mocha in the context of a npm script works but running it directly from command line does not
So when I run npm run test_w_emulator or npm run test_w_pure
my mocha test completes properly
package.json
"scripts": {
"test_w_emulator": "sh ./test.sh",
"...
0
votes
0
answers
36
views
How to refactor my index.js page so that my db connection isn't called when running tests
I'm building an API and used a tutorial as a basis, but it didn't cover testing, so I'm looking too add testing as I'm going. But when I import my app object into the test it's running all the code (...
0
votes
0
answers
39
views
Error when calling a contract function with web3.js
I'm working on a smart contract test using Ganache and Web3.js. My contract deploys without errors, but when I try to call a function, I encounter an error.
Here’s my code:
const assert = require('...
1
vote
0
answers
38
views
How to mock a node module import in node js
I am using mocha as my testing environment in my node project and Sinon to stub and mock dependencies.
I have a File Factory.js as
import fs from 'fs'
class Factory{
create = async(options) => {...
1
vote
0
answers
34
views
How does one get the ID from the response body with Mocha test, then use that ID and delete the item?
I am creating a location on the API, the location gets created but then populates an ID, this ID changes all the time. How do I write my Mocha tests to get the ID of the created location, even though ...
0
votes
0
answers
36
views
Issues with Mocking S3 Multipart Upload After Migrating from AWS SDK v2 to v3
I'm trying to run a test. It worked fine with AWS SDK v2, but after migrating to v3 using codemod,I'm facing issues.
This is my index.spec.js to test the test using mocha and sinon. My test is getting ...