2,920 questions
1
vote
1
answer
345
views
chai-http error Exception during run: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined
I have a problem using chai-http for testing, when I use npm test or mocha I get this error
Exception during run: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\...\...
0
votes
1
answer
191
views
Insomnia returning Error: Invalid Chai property: jsonSchema
I’m trying to validate a JSON response in Insomnia against a predefined schema using an after-response script. Here’s my script:
var statisticsSchema = {
"$schema": "http://json-...
1
vote
0
answers
183
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
vote
1
answer
511
views
How to dynamic import chai in CommonJS?
chai latest version 5.1.2 move to ESModule. Is it possible continue use it in CommonJS file? chai is just a dev dependency in my project, used for unit test. I don't want to upgrade my modules to ...
0
votes
1
answer
50
views
transfer function does not working correctly on ERC20 presale smart contract while testing using Chai and Hardhat
I have written ERC20 token presale smart contract.
I have defined token transfer function as follows:
function transferTokensToPresale(uint256 presaleSupplyAmount_) public onlyOwner returns (bool) {
...
2
votes
1
answer
111
views
Cypress tests are passing when they should fail [closed]
I'm writing Cypress tests and running them headless in terminal. The tests are passing even when they should fail.
For example writing this code:
describe('Website Landing', () => {
it.only(...
3
votes
0
answers
209
views
Upgraded to Chai 5.x, converted whole node project to ESM modules, test run fails with unhelpful error messages
I have a node server that was originally written in 2018-19 with require and module.exports syntax. I recently upgraded to Chai 5.1, which meant I needed to convert every file in my project to ESM ...
0
votes
0
answers
45
views
Issue writing unit tests for a jQuery datepicker plugin
the start of my plugin
(function(factory) {
if (typeof define === "function" && define.amd) {
define(["jquery", "jquery-ui-dist"], factory);
} else {
...
-1
votes
1
answer
118
views
Simplest Chai Spies syntax
I'm having problems with Chai Spies. I have a hard time catching how the syntax works.
Here, I am trying the simple example. The myMap function which mimics the array.map method:
function myMap(...
1
vote
1
answer
510
views
Playwright with chai, can't check element visibility
I'm relatively new with Playwright, and despite PW already have an expect function library, I am trying chai to check if can be useful to my tests and their readability.
So I did (since I'm using ...
0
votes
1
answer
198
views
Is it possible to use k6chaijs with async function? For example in k6 browser tests?
I'd like to use k6chaijs with k6 browser module, but I have observed that messages are printed in wrong order.
export default () => {
describe('New page verifier', async () => {
...
-1
votes
1
answer
109
views
Confused if I should use a fake or a stub?
Quite new to unit testing. I am writing unit tests for my code using Chai+Mocha and Sinon and I am stuck at a point because I am not able to decide whether I should use a Sinon stub or a fake. I have ...
0
votes
1
answer
261
views
Issue with chai-http middleware when using dynamic imports in chai version 5.1.1
I am currently using npm chai version 5.1.1 which now only supports import and not require. I have used dynamic imports which are working fine. However, when I am using the chai-http middleware with ...
0
votes
0
answers
57
views
How can I get the stack trace of unexpected errors with Chai?
I am using Chai with Mocha. I write tests something like this:
expect(() => f(a, b)).to.throw('Sriharikota we have a problem.')
I want to show the stack trace of the original error when it does ...
0
votes
1
answer
807
views
Can you run Chai tests using Mocha for ES6 modules?
I am trying to run an API test for getting the version using Chai. I have this test in src/tests/version.tests.js. I am using mocha ./src/tests/**/*.tests.js to run it.
For some reason I get this ...