graphql.macro icon indicating copy to clipboard operation
graphql.macro copied to clipboard

fs__WEBPACK_IMPORTED_MODULE_1___default.a.realpathSync is not a function

Open hongbo-miao opened this issue 5 years ago • 3 comments

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.

fs__WEBPACK_IMPORTED_MODULE_1___default.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 avatar Oct 03 '20 22:10 hongbo-miao

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...

hongbo-miao avatar Oct 03 '20 22:10 hongbo-miao

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.

zaneclaes avatar Nov 09 '20 20:11 zaneclaes

Any update for this?

phosph avatar Apr 29 '21 15:04 phosph