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

visitedTypes in the testkit does not include enums #1941

Open
BryBo617 opened this issue Nov 3, 2021 · 0 comments
Open

visitedTypes in the testkit does not include enums #1941

BryBo617 opened this issue Nov 3, 2021 · 0 comments

Comments

@BryBo617
Copy link

BryBo617 commented Nov 3, 2021

While writing a test I discovered that enums are not listed in the visitedTypes. And cause testModule to fail.

My test:

it('Resolves query', async () => {
      const mockData = {
        contact: {
          email: 'this@that.com',
          name: 'Bruce',
          phone: '913-555-1212',
        },
      };

      const mockResult = {
        _id: '1e9f12ca136a0d24b4a08821',
        ...mockData,
      };

      const app = testkit.testModule(myModule, {
        inheritTypeDefs: [module1, module2],
        providers: [
          {
            provide: myProvider,
            useValue: {
              getOne() {
                return {
                  ...mockData,
                };
              },
            },
          },
        ],
      });

      const result = await testkit.execute(app, {
        document: gql`
          query {
            getFromDatabase(filter: { _id: "1e9f12ca136a0d24b4a08821" }) {
              _id
              contact {
                email
                name
                phone
              }
            }
          }
        `,
      });

      expect(result.errors).toBeFalsy();
      expect(typeof result.data.getFromDatabase).toBe('object');
      expect(result.data.getFromDatabase).toEqual(mockResult);
    })

A workaround I have found is to include the Module with the enum types in both the inheritTypeDefs and the modules.

Environment:

  • OS: MAC
  • @graphql-modules/...:
  • NodeJS: 14.17.6
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