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

Stubbed function not invoked #486

Closed
benhowdle89 opened this issue May 25, 2022 · 0 comments
Closed

Stubbed function not invoked #486

benhowdle89 opened this issue May 25, 2022 · 0 comments

Comments

@benhowdle89
Copy link

Using this simple case:

const test = require("ava");
const td = require("testdouble");

const reducer = async (state) => {
  const existing = await state.foo();
  console.log("existing:", existing);
};

test("foo", async (t) => {
  const foo = td.func(".foo");

  const state = td.object({
    foo
  });

  td.when(foo()).thenResolve({
    id: "123"
  });

  await reducer(state);
});

existing: undefined is logged, whereas I believe, and intend it to, log: existing: { id: "123" }

am I missing something very basic here?

Reproduce here: https://codesandbox.io/s/relaxed-montalcini-lzfszy?file=/index.js

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