evenchange4 / graphql.macro

Compile GraphQL AST at build-time with babel-plugin-macros.
MIT License
239 stars 21 forks source link

fs__WEBPACK_IMPORTED_MODULE_1___default.a.realpathSync is not a function #118

Open hongbo-miao opened 3 years ago

hongbo-miao commented 3 years ago

I am using graphql.macro to import .graphql file in a create-react-app app. It works well.

However, when I try to run a Cypress test, I got error

The following error originated from your test code, not from Cypress.

fsWEBPACK_IMPORTED_MODULE1default.a.realpathSync is not a function

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

Check your console for the stack trace or click this message to see where it originated from. client/node_modules/graphql.macro/es/utils/resolveImportPath.js:3:13

  1 | import path from 'path';
  2 | import fs from 'fs';
> 3 | var CMD = fs.realpathSync(process.cwd());
    |             ^
  4 | var jsconfigPath = path.resolve(CMD, 'jsconfig.json');
  5 | var jsconfigInclude;
  6 | 
image

I know Cypress is using Mocha internally. Any help will be great. Thanks

hongbo-miao commented 3 years ago

I found https://github.com/apollographql/graphql-tag#testing

Testing environments that don't support Webpack require additional configuration. For Jest use jest-transform-graphql.

Hmm, what about Cypress which built on Mocha...

zaneclaes commented 3 years ago

Same problem, except on production :( Can't get this plugin to work at all, and have no way to load my gql files in my CRA.

phosph commented 3 years ago

Any update for this?