Skip to content

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

@CloudNStoyan

Description

@CloudNStoyan

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);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions