saleor-dashboard/testUtils/api.ts
Michał Droń d5c9a3dae8
Add trailing commas (#2062)
* Require trailing commas

* Add trailing commas

* Add trailing commas in testUtils dir

* Add trailing commas
2022-06-21 11:36:55 +02:00

49 lines
1.2 KiB
TypeScript

import { ApolloClient, InMemoryCache } from "@apollo/client";
import { BatchHttpLink } from "@apollo/client/link/batch-http";
import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import { Polly } from "@pollyjs/core";
import FSPersister from "@pollyjs/persister-fs";
import { createFetch } from "@saleor/sdk";
import path from "path";
import { setupPolly } from "setup-polly-jest";
Polly.register(NodeHttpAdapter);
Polly.register(FSPersister);
function setupApi() {
setupPolly({
adapters: ["node-http"],
matchRequestsBy: {
headers: false,
url: {
hash: false,
hostname: false,
password: false,
pathname: false,
port: false,
protocol: false,
query: false,
username: false,
},
},
persister: "fs",
persisterOptions: {
fs: {
recordingsDir: path.resolve(__dirname, "../recordings"),
},
},
});
const cache = new InMemoryCache();
const link = new BatchHttpLink({
fetch: createFetch(),
uri: process.env.API_URI || "http://localhost:8000/graphql/",
});
const apolloClient = new ApolloClient({
cache,
link,
});
return apolloClient;
}
export default setupApi;