Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'queueMicrotask' shouldn't be the only way the foundation/promise tests pass #49

Open
CloudNStoyan opened this issue Apr 30, 2024 · 0 comments

Comments

@CloudNStoyan
Copy link

The only way the tests pass while the onFulfilled and onRejected functions are not invoked synchronously is when the onFulfilled and onRejected functions are delayed specifically with queueMicrotask.

While the linked spec for the exercise doesn't specifically mention queueMicrotask instead it mentions: setTimeout, setImmediate, proccess.nextTick which by the spec are valid ways of making sure onFulfilled and onRejected are not called synchronously:
https://promisesaplus.com/#point-67:~:text=Here%20%E2%80%9Cplatform%20code,handlers%20are%20called.

await waitForPromises();
const nextPromise = promise.then(onFulfilled, onRejected);

it("`.then` onFulfilled gets called with resolved value", async () => {
const { onFulfilled, resolvedValue } = await thirdSetup();
expect(onFulfilled).toHaveBeenCalledTimes(1);
expect(onFulfilled).toHaveBeenCalledWith(resolvedValue);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant