Open zhammer opened 5 years ago
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') });
});
@zhammer why are you using cucumber
here for?
just by chance on my project I'm using https://github.com/TheBrainFamily/cypress-cucumber-preprocessor. But not necessary for this example.
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.