File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -144,3 +144,41 @@ getCustomTransformers: (program: any) => ({
144
144
before: [require (' @nestjs/graphql/plugin' ).before ({}, program)]
145
145
}),
146
146
```
147
+
148
+ #### Usage with ` ts-jest `
149
+ When using e2e tests with this plugin you probably will run into issue with compiling schema
150
+ like ` Object type <name> must define one or more fields. `
151
+
152
+ This happens because jest configuration does not import ` @nestjs/graphql/plugin ` plugin anywhere.
153
+
154
+ To fix this, create the following file anywhere:
155
+ ``` javascript
156
+ const transformer = require (' @nestjs/graphql/plugin' );
157
+
158
+ module .exports .name = ' nestjs-graphql-transformer' ;
159
+ module .exports .version = 1 ;
160
+
161
+ module .exports .factory = cs => {
162
+ return transformer .before (
163
+ {
164
+ // your @nestjs/graphql/plugin options(can be empty)
165
+ },
166
+ cs .tsCompiler .program ,
167
+ );
168
+ };
169
+ ```
170
+
171
+ Then import it within yours ` jest.config.js `
172
+ ``` javascript
173
+ module .exports = {
174
+ ...
175
+ globals: {
176
+ ' ts-jest' : {
177
+ astTransformers: {
178
+ before: [' <path to plugin>' ],
179
+ },
180
+ },
181
+ },
182
+ ...
183
+ }
184
+ ```
Original file line number Diff line number Diff line change @@ -159,3 +159,40 @@ getCustomTransformers: (program: any) => ({
159
159
before: [require (' @nestjs/swagger/plugin' ).before ({}, program)]
160
160
}),
161
161
```
162
+
163
+ #### Usage with ` ts-jest ` in e2e tests
164
+
165
+ You need to do the following steps in order to make ` jest ` e2e tests working with this plugin.
166
+ This happens because ` jest ` configuration does not import ` @nestjs/swagger/plugin ` plugin anywhere.
167
+
168
+ To fix this, create the following file anywhere:
169
+ ``` javascript
170
+ const transformer = require (' @nestjs/swagger/plugin' );
171
+
172
+ module .exports .name = ' nestjs-swagger-transformer' ;
173
+ module .exports .version = 1 ; // you should change this anytime you change the configuration below
174
+
175
+ module .exports .factory = cs => {
176
+ return transformer .before (
177
+ {
178
+ // your @nestjs/swagger/plugin options(can be empty)
179
+ },
180
+ cs .tsCompiler .program ,
181
+ );
182
+ };
183
+ ```
184
+
185
+ Then import it within yours ` jest.config.js `
186
+ ``` javascript
187
+ module .exports = {
188
+ ...
189
+ globals: {
190
+ ' ts-jest' : {
191
+ astTransformers: {
192
+ before: [' <path to plugin>' ],
193
+ },
194
+ },
195
+ },
196
+ ...
197
+ }
198
+ ```
You can’t perform that action at this time.
0 commit comments