Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
config.devServer.before(app, server);
await waitForExpect(() => {
expect(app.get).toHaveBeenCalled();
});
const [endpoint, middlewareProxy] = app.get.mock.calls[0];
expect(endpoint).toBe('/graphiql');
expect(middlewareProxy).toBeInstanceOf(Function);
const req = {};
const res = {};
middlewareProxy(req, res);
await waitForExpect(() => {
expect(playgroundMiddleware).toHaveBeenCalled();
});
expect(fs.readFile).toHaveBeenCalledTimes(2);
expect(playgroundMiddleware.mock.calls[0][0]).toMatchObject({
endpoint: '/graphql',
tabs: [
{
endpoint: '/graphql',
name: 'path/to/query.graphql',
query: '{ foo { bar } }'
},
{
endpoint: '/graphql',
name: 'path/to/otherQuery.graphql',
query: '{ foo { bar, baz } }'
}
]
});
expect(middleware).toHaveBeenCalledWith(req, res, expect.any(Function));
config.devServer.after(app, server);