Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples using fs.readFileSync #5

Open
zhammer opened this issue Mar 16, 2019 · 3 comments
Open

Examples using fs.readFileSync #5

zhammer opened this issue Mar 16, 2019 · 3 comments

Comments

@zhammer
Copy link

zhammer commented Mar 16, 2019

Are there any examples of using this plugin with fs.readFileSync? I'd prefer to read in the graphql schema than import a json introspection query.

@zhammer
Copy link
Author

zhammer commented Mar 17, 2019

Ah this was my confusion. Didn't realize this was being called in plugins/index.js. Here's my working setup:

// cypress/plugins.index.js
const cucumber = require('cypress-cucumber-preprocessor').default
const fs = require('fs');

const graphQlSchema = fs.readFileSync('schema.graphql', 'utf8');

module.exports = (on, config) => {
  on('file:preprocessor', cucumber())

  config.env.GRAPHQL_SCHEMA = graphQlSchema;
  return config;
}

then in my tests:

// cypress/.../steps.js
beforeEach(() => {
  cy.server();
  cy.mockGraphql({ schema: Cypress.env('GRAPHQL_SCHEMA') });
});

@rodrigofd
Copy link

rodrigofd commented Aug 14, 2019

@zhammer why are you using cucumber here for?

@zhammer
Copy link
Author

zhammer commented Aug 14, 2019

just by chance on my project I'm using https://github.com/TheBrainFamily/cypress-cucumber-preprocessor. But not necessary for this example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants