Why am I getting "Error: Resolution method is overspecified"?

why do i keep getting sick every month
why do i keep getting a cold every few weeks
constantly getting colds
i keep getting sick over and over
why am i always angry and irritated
why do i keep getting sick every other week
why do i get sick every year at the same time
i keep getting colds one after another

After the upgrade, Mocha can not even run a simple test here is the code

const assert = require('assert');

it('should complete this test', function (done) {
  return new Promise(function (resolve) {
    assert.ok(true);
    resolve();
   })
  .then(done);
});

I took this code from here

I understood that it now throws an exception Error: Resolution method is overspecified. Specify a callback * or * return a Promise; not both.

But how to make it work? I did not understand. I have

node -v 6.9.4

mocha -v 3.2.0

How to run this code are now in a new and correct format?

Just drop .then(done); and replace function(done) with function()

You are returning a Promise so calling done is redundant as it said in error message

In the elder versions you had to use callback in case of async methods like that

it ('returns async', function(done) {
   callAsync()
   .then(function(result) {
      assert.ok(result);
      done();
   });
})

Now you have an alternative of returning a Promise

it ('returns async', function() {
  return new Promise(function (resolve) {
     callAsync()
       .then(function(result) {
          assert.ok(result);
          resolve();
       });
  });
})

But using both is misleading (see for example here https://github.com/mochajs/mocha/issues/2407)

Why Am I So Angry: Causes, Symptoms, and Treatments, an event like bad traffic or getting in a car accident; memories of a traumatic or enraging event. In other cases, an anger problem may be caused� The risk for getting pregnant is also lower, though not zero. Full bladder. The clitoris, vagina, and urethra are tightly packed in your pelvis. When the bladder is full, it may put pressure on

Mocha allows to either use a callback:

it('should complete this test', function (done) {
  new Promise(function (resolve) {
    assert.ok(true);
    resolve();
   })
  .then(done);
});

OR return a promise:

it('should complete this test', function () {
  return new Promise(function (resolve) {
    assert.ok(true);
    resolve();
   });
});

// Or in the async manner
it('should complete this test', async () => {
    await Promise.resolve();
    assert.ok(true);
});

You can't do both.

Why Am I Having Heart Palpitations? 14 Possible Causes, If your heart flutters or pounds, it could be because you haven't worked out in a while and you're out of condition. An irregular heartbeat, or arrhythmia, can also� Read 48 answers by scientists with 45 recommendations from their colleagues to the question asked by Mohamad Nur Azshary Mohd Salleh on Apr 10, 2014

I had to removed the done from the function parameter and the done() of the function call Before

   before(async function (done) {
        user = new User({ ...});
        await user.save();
        done()
    });

After

   before(async function () {
        user = new User({ ...});
        await user.save();
    });

These works for me

Why Am I Dizzy? 7 Possible Causes of Dizziness and How To Treat It, Your doctor will look at all your symptoms and overall health to figure out what's dizzy and you faint, fall, or can't walk or have any of the following: How to Keep Your Mind Sharp With MS � Is It MS or Am I Having a Stroke? The blisters usually break and form a sore that crusts over. They will generally heal without treatment within a few weeks.. This article explores why some people get cold sores frequently, as

I had this same issue. A lot of times Mocha is paired with another library called Chai. Chai has a package called "chai-as-promised". It gives you the super simple ability to write less code and test promises. In your case of just testing if a promise resolves, it seems perfect.

const chai = require('chai');
const chaiAsPromised = require("chai-as-promised");
const should = require("chai").should();
chai.use(chaiAsPromised);

describe("Testing with correct syntax and non repeated names", () => {
    it("Should give us a positive response", () => {
      graphQL.sendToGQL(model,"specialEndpoint").should.eventually.be.an("Object");
    })
})

'Spam' or 'phishing': Why am I getting so many of these messages , Spam or phishing: Why am I getting so many of these messages recently and what should I do with them? Why am i getting so much junk mail?! Over the last few weeks my Junk Email folder has gone from maybe 1 or 2 junk emails daily to 25-20 daily. Over the last few months I have been reporting all these as "Phishing Spam' and I have blocked the senders but it keeps on coming.

If you don't have callbacks, prior answers (which suggest deleting the done) is correct.

If need to both await some external promise, and then exercise a callback/errback-based implementation in your test, that solution doesn't help you.

You can use a library like pify to convert the callback API to use promises.

Alternatively, you can use a Latch in your callback:

  it("test", async () => {
    const l = new Latch()
    const v = await promiseValue()
    s.methodThatTakesCallback((err, result) => {
      expect(result).to.eql(expected)
      l.resolve() // < notifies mocha your test is done
    })
    return l.promise
  })

In TypeScript, here's a very stripped-down Latch implementation:

/**
 * Simple one-count concurrent barrier
 */
export class Latch {
  readonly promise: Promise<void>
  resolve!: () => void
  constructor() {
    this.promise = new Promise<void>(resolve => (this.resolve = resolve))
  }
}

Why am I getting lazier day by day?, Do you have any goals that you are working toward? Having goals will motivate you to complete your tasks. You need a plan to see that your goals are met. If you � Many parts of your body -- including your eyes, brain, inner ear, and nerves in your feet and spine-- work together to keep you balanced.When a part of that system is off, you can feel dizzy. It

Why am I getting depressed more day by day?, Noone on this earth will ever be depressed if he/she makes himself realise that depression isn't the thing for them. Right now I'm sure you must be feeling like� You can access Get My Payment using an ITIN, but in most cases, the law does not allow an Economic Impact Payment (EIP) for individuals who file a return using an ITIN. . The only exception is when two spouses file a joint tax return and either spouse is a member of the U.S. Armed Forces at any time during the taxable year, in which case only one spouse needs to have a valid

Why Am I Getting Pimples On My Face?, So what causes pimples and what steps can we take to prevent these skin breakouts? Did you know that pimples fall under the category of acne? That’s why it’s important to let your doctor know if gas is getting in the way of your life. He can run tests to help figure out exactly what’s causing your problems and find the treatment

Why am I getting more pimples these days? We tell you why and , It is true that we are avoiding some things that would negatively affect our skin, but confinement due to Covid-19 also causes certain factors to cause lesions on � Get plenty of rest and drink plenty of liquids. A mild fever is 101.4°F (38.6°C) or less. Cover yourself with a light sheet and avoid heavy blankets or clothing, which can raise your body

Comments
  • Another alternative: you can change function () to async function () and return to await. Is that accurate? Thanks.