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

Mock is not working(TestCafe) #70

Open
deepakarya74 opened this issue Sep 28, 2021 · 0 comments
Open

Mock is not working(TestCafe) #70

deepakarya74 opened this issue Sep 28, 2021 · 0 comments

Comments

@deepakarya74
Copy link

I am using a test cafe in my project. Due to multiple graphQL requests to build a report, I thought to use your solution. I have looked your another example- https://github.com/abhinaba-ghosh/graphql-mock-e2e-example

1 I have graphQL schema defined in the file.
2 I saw your example, in my project they are using a huge query, I gave the sample at the bottom. Not the exact query. If you can share something huge query and schema that working code. It really helps. I have very little knowledge of Graphql.
3 I tried code as mentioned below but it is not able to intercept the request. I am not getting any errors.

1 const mock = {
Query: () => ({
data: ({ storeId }) => ,
}),
};

2 const query = `
query getReport($A: String!, $B: String, $C: Int, $D: Int) {
getReport($A: String!, $B: String, $C: Int, $D: Int) {

}
`

const requestMock = RequestMock()
.onRequestTo({ url: 'https:///graphql', method: 'POST' })
.respond(async (req, res) => {
await mockGraphQL(
{
schema: graphQLSchemaFromFile(
${process.cwd()}/data/scanReport/queries/mySchema.graphql
),
mock,

},
req,
res
)
}, 200, {
'content-type': 'application/json',
'access-control-allow-credentials': true,
'access-control-allow-origin': '',
})

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

1 participant