Category : mocha.js

I use supertest, chai and mocha to run api-testing. I have the following code: app.js app.get(‘/post’, async (req, res, next) => { await postModel.find(); console.log("co xuong duoi la duoc"); res.json({loi: "hi"}).status(200) // postModel.find(() => res.json({loi: "hi"}).status(200)); //; }) test.js describe(‘GET /post’, () => { before(() => { db.connect() // .then(() => done()) // .catch((err) => ..

Read more

I have a web component I’ve built which is bundled (using Rollup) into a UMD and ESM package. The src/index.js basically looks like this. import html from ‘template.html’; import css from ‘styles.css’; export class MyComponent extends window.HTMLElement { constructor() { super(); this.attachShadow({ mode: ‘open’ }); } } export default (function() { window.customElements.define(‘my-component’, MyComponent); })() I’m ..

Read more

I’m learning automation and I’m using the webdriverIO framework. I’m training with https://demos.mqtt.cool/chat/ website, and actually I don’t know how to verify that user 2 received message from user1, maybe someone can suggest how to do it? Steps file import { step } from ‘mocha-steps’ import DemosPage from ‘../pageobjects/demosMqtt.page’ import { generateNickName,generateRandomMessage} from ‘../utils/randomGenerate’ const ..

Read more

I’m learning how to unit test solidity code with mocha, and I get this error from simple code: contract hello{ function returnString() public pure returns(string memory){ return "this"; } } When testing without try/catch: const Hello = artifacts.require(‘hello’); contract(‘hello’, () => { it(‘should return string’, async () => { const hello = await Hello.deployed(); const ..

Read more

I have an issue in refreshing the html and json files from Mochawesome The setup is with Selenium/NodeJs Any idea will be welcome! packaje.json file: explanation line ("test": "mocha tests.js –reporter mochawesome && concurrently "http-server -a localhost -p 3000" "opener http://localhost:3000/mochawesome-report/mochawesome.html"") – start the tests with mocha, passing the tests to the mochawesome reporter, starting ..

Read more

it(‘this test should run’, function (done) { … SuiteA.ParentFunction( function (x,y) { SuiteB.prototype.myFunction.should.have.been.called; done(); }); … }); This test was passing until I changed the function inside myFunction to an async function. myFunction is not being called itself, it’s parent is being called but it is expected that it will also be called by the ..

Read more

I’m currently working on a fork of passport-jwt which accepts multiple jwks providers in an array. It is actually working well, but I’m having an issue with automated testing, using the existing tests for passport-jwt as it should be fully backwards compatible. My repository is here: https://github.com/MeStrak/passport-jwt/tree/9ab3f2d8e99079160ff1a56fd30078c1ec337dee (the link is to the current repo version ..

Read more

Using mocha and chai, I’m trying to pass my second test to get the rejected promise, but instead I get this error Error: the string "error" was thrown, throw an Error. function fn(arg) { return new Promise((resolve, reject) => { if (arg) { resolve(‘success’) } else { reject(‘error’) } }) } describe(‘Interpreting status’, function() { ..

Read more