graphql-hive / graphql-hive/graphql-modules

Expose TestModuleConfig interface

Open
#2,113 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
113
Avg merge
3h 36m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**

In tests, I may want to define a variable of type `TestModuleConfig` scoped for the entire test suite. It is not possible to get compile errors at the declaration site because `TestModuleConfig` is not exposed. Further, if I want to modify that object later, I won't receive compile time errors at that line of code.

**Describe the solution you'd like**

Export this type to users of `graphql-modules` https://github.com/Urigo/graphql-modules/blob/75552e6775202a8c8a69d3aa587033d9c0987da2/packages/graphql-modules/src/testing/test-module.ts#L29-L38

**Describe alternatives you've considered**

Copy/pasta of the type into a project or each test file is not ideal, especially if the type changes on this project.

**Additional context**
If the type is exposed, users would be able to do this.
```ts
// using something like Jest
describe('my test', () => {
let config: TestModuleConfig;

beforeEach(() => {
config = { ...baseConfigStuff };
});

test('first test', () => {
const app = testkit.mockModule(someModule, config);
});

test('second test which modifies config', () => {
config.typeDefs = 'wrong type'; // GET AN ERROR RIGHT HERE'
const app = testkit.mockModule(someModule, config);
});
```

Perhaps there are other types worth exporting as well, but this is one I've come across thus far.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.