Promises in JavaScript

I’m trying to solve this , Promises in JavaScript

I want to test only promisify function, so my code is below.

export const promisify = (func) => {
  return ((value) => new Promise((resolve, reject) => {
    func(value, (error, data) => {
      if(error) reject(error)
      resolve(data)
    })}));
};

export const all = () => {
  return;
};

export const allSettled = () => {
  return;
};

export const race = () => {
  return;
};

export const any = () => {
  return;
};

But, I can see the message below, and I can’t know why this message happens.

An error occurred while running your tests. This might mean that there was an issue in our infrastructure, or it might mean that you have something in your code that’s causing our systems to break.

Please check your code, and if nothing seems to be wrong, try running the tests again.

What should I do?

2 Likes

Your code is unlikely to be the cause of that error. If you want to reliably avoid it, solve exercises locally on your machine.

If you try testing again, do you get the same message? (And again, and again?)

Thank you for comment.

I’ll try locally on my machine.

If you try testing again, do you get the same message? (And again, and again?)
Yes, still now, I get the same message.

It’s expecting promises from those functions. Because they’re not, the test runner is “waiting” for something to resolve that will never resolve or reject.

If you want to try this, you can replace the return with return Promise.reject(new Error('not yet implemented')).

Oof. Could it be possible to have this be a regular test failure rather than a test runner failure?

You can’t tell the test runner “fail if not promise” because if it is a promise, then it keeps running.

1 Like

I had the same error Message with the JS Exercise “Elyses Enchantment”. I could not find an error so I went to bed and next day I started the editor again but this time no error message appeared and my solution was fine.

That may have been a hiccup in the infrastructure!

I think reject function has wrong.
I commented out reject function, code is below, then I tried tests.
I didn’t recieve the message.
All tests ran (the result was that 3 tests passed and 24 tests failed).

export const promisify = (func) => {
  return ((value) => new Promise((resolve, reject) => {
    func(value, (error, data) => {
      //if(error) reject(error)
      resolve(data)
    })}));
};

export const all = () => {
  return;
};

export const allSettled = () => {
  return;
};

export const race = () => {
  return;
};

export const any = () => {
  return;
};