Usage with jest
See original GitHub issueHi.
I’ve managed to use this in my project at runtime, however when running my tests with jest I get
({“Object.<anonymous>”:function(module,exports,require,__dirname,__filename,global,jest){mutation loginUser($emailAddress: String!, $password: String!, $deviceToken: String!) {
SyntaxError: Unexpected identifier
Tried using https://github.com/keplersj/jest-raw-loader but didn’t work either as I believe that just imports the file as a string and this plugin passes it through graphql-tag
first, and I instead receive
Invariant Violation: Argument of undefined passed to parser was not a valid GraphQL DocumentNode. You may need to use ‘graphql-tag’ or another method to convert your operation into a document
Is there a way to transform files in jest the same way this plugin does at runtime?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Solution with ts-jest is here: https://github.com/kulshekhar/ts-jest/issues/489#issuecomment-401548565
10/10 for enthusiasm :p
Currently I’ve stopped trying to fix my original use case to work, I just transpile first and test the outputted JS. I do however like the sound of
requireGql
, and would like give it a try when ready 😄