# dataSources not coming through on Jest Tests

**URL:** <https://community.apollographql.com/t/datasources-not-coming-through-on-jest-tests/6327>\
**Category:** General\
**Tags:** server\
**Created:** [June 1, 2023, 7:52pm UTC](https://community.apollographql.com/t/datasources-not-coming-through-on-jest-tests/6327 "2023-06-01T19:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zach](https://avatars.discourse-cdn.com/v4/letter/z/51bf81/32.png) [@zach](https://community.apollographql.com/u/zach)\
**Post date:** [June 1, 2023, 7:52pm UTC](https://community.apollographql.com/t/datasources-not-coming-through-on-jest-tests/6327/1 "2023-06-01T19:52:17Z")

</div>

My contextValues / dataSources don’t seem to be coming through on my jest tests. When I console.log in the actual resolver, I see the dataSource, but the expect returns null. Also, aside – is it always required to assert a single king in order to retrieve the data? This is strange.

Here is my Test Server:

```auto
const schema = makeExecutableSchema({
  resolvers,
  resolverValidationOptions: { requireResolversForResolveType: 'ignore' },
  typeDefs,
});

interface ServerContext {
  token?: String;
  dataSources: MockedDataSourcesTypes;
}

export const apolloTestServer = new ApolloServer<ServerContext>({
  schema,
});

```

Here is a Query resolver function

```auto
  geThingById: async (_, { id }, { dataSources }) => {
     const { data } = await dataSources.thing.getThing(id);
     console.log('DATA -- this returns with dataSources', data, dataSources);
     return data;
  },

```

Here is my test:

```auto
  describe('getThing', () => {
    it('return the correct query response', async () => {
      const { body } = await apolloTestServer.executeOperation(
        { query: queries.geThingById },
        { contextValue: { dataSources: mockedDataSources } }
      );
      assert(body.kind === 'single');
      expect(body.singleResult).toMatchObject({
        errors: undefined,
        data: {
          geThingById: {...myData}
        }
      });
    });
  });

```

The console returns well, but data.getThing is null. Wondering if I’m missing something

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/datasources-not-coming-through-on-jest-tests/6327/2 "2025-02-06T20:48:52Z")

</div>


