wip
This commit is contained in:
parent
24f4aecd97
commit
b5029deca0
4 changed files with 2558 additions and 0 deletions
2507
package-lock.json
generated
2507
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -83,6 +83,9 @@
|
||||||
"@babel/preset-react": "^7.7.4",
|
"@babel/preset-react": "^7.7.4",
|
||||||
"@babel/preset-typescript": "^7.7.4",
|
"@babel/preset-typescript": "^7.7.4",
|
||||||
"@babel/runtime": "^7.7.6",
|
"@babel/runtime": "^7.7.6",
|
||||||
|
"@pollyjs/adapter-node-http": "^5.0.0",
|
||||||
|
"@pollyjs/core": "^5.0.0",
|
||||||
|
"@pollyjs/persister-fs": "^5.0.0",
|
||||||
"@storybook/addon-storyshots": "^5.2.8",
|
"@storybook/addon-storyshots": "^5.2.8",
|
||||||
"@storybook/react": "^5.1.9",
|
"@storybook/react": "^5.1.9",
|
||||||
"@testing-library/react-hooks": "^1.1.0",
|
"@testing-library/react-hooks": "^1.1.0",
|
||||||
|
@ -93,6 +96,8 @@
|
||||||
"@types/jest": "^24.0.24",
|
"@types/jest": "^24.0.24",
|
||||||
"@types/lodash-es": "^4.17.3",
|
"@types/lodash-es": "^4.17.3",
|
||||||
"@types/moment-timezone": "^0.5.12",
|
"@types/moment-timezone": "^0.5.12",
|
||||||
|
"@types/pollyjs__adapter-node-http": "^2.0.0",
|
||||||
|
"@types/pollyjs__persister-fs": "^2.0.0",
|
||||||
"@types/react": "^16.9.16",
|
"@types/react": "^16.9.16",
|
||||||
"@types/react-dom": "^16.8.5",
|
"@types/react-dom": "^16.8.5",
|
||||||
"@types/react-dropzone": "^4.2.2",
|
"@types/react-dropzone": "^4.2.2",
|
||||||
|
@ -135,6 +140,7 @@
|
||||||
"jest-file": "^1.0.0",
|
"jest-file": "^1.0.0",
|
||||||
"lint-staged": "^9.4.2",
|
"lint-staged": "^9.4.2",
|
||||||
"mock-apollo-client": "^0.4.0",
|
"mock-apollo-client": "^0.4.0",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"react-intl-translations-manager": "^5.0.3",
|
"react-intl-translations-manager": "^5.0.3",
|
||||||
"react-test-renderer": "^16.12.0",
|
"react-test-renderer": "^16.12.0",
|
||||||
|
@ -142,6 +148,8 @@
|
||||||
"require-context.macro": "^1.1.1",
|
"require-context.macro": "^1.1.1",
|
||||||
"rimraf": "^3.0.0",
|
"rimraf": "^3.0.0",
|
||||||
"start-server-and-test": "^1.11.0",
|
"start-server-and-test": "^1.11.0",
|
||||||
|
"setup-polly-jest": "^0.9.0",
|
||||||
|
"testcafe": "^1.3.3",
|
||||||
"ts-jest": "^24.2.0",
|
"ts-jest": "^24.2.0",
|
||||||
"tsconfig-paths-webpack-plugin": "^3.2.0",
|
"tsconfig-paths-webpack-plugin": "^3.2.0",
|
||||||
"webpack": "^4.35.3",
|
"webpack": "^4.35.3",
|
||||||
|
|
0
src/auth/AuthProvider.test.ts
Normal file
0
src/auth/AuthProvider.test.ts
Normal file
43
testUtils/api.ts
Normal file
43
testUtils/api.ts
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import NodeHttpAdapter from "@pollyjs/adapter-node-http";
|
||||||
|
import { Polly } from "@pollyjs/core";
|
||||||
|
import FSPersister from "@pollyjs/persister-fs";
|
||||||
|
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||||
|
import ApolloClient from "apollo-client";
|
||||||
|
import { BatchHttpLink } from "apollo-link-batch-http";
|
||||||
|
import fetch from "node-fetch";
|
||||||
|
import path from "path";
|
||||||
|
import { setupPolly } from "setup-polly-jest";
|
||||||
|
|
||||||
|
function setupApi() {
|
||||||
|
Polly.register(NodeHttpAdapter);
|
||||||
|
Polly.register(FSPersister);
|
||||||
|
setupPolly({
|
||||||
|
adapterOptions: {
|
||||||
|
fetch: {
|
||||||
|
context: global
|
||||||
|
}
|
||||||
|
},
|
||||||
|
adapters: ["node-http"],
|
||||||
|
persister: "fs",
|
||||||
|
persisterOptions: {
|
||||||
|
fs: {
|
||||||
|
recordingsDir: path.resolve(__dirname, "../recordings")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
recordIfMissing: true
|
||||||
|
});
|
||||||
|
const cache = new InMemoryCache();
|
||||||
|
const link = new BatchHttpLink({
|
||||||
|
// @ts-ignore
|
||||||
|
fetch,
|
||||||
|
uri: "http://localhost:8000/graphql/"
|
||||||
|
});
|
||||||
|
const apolloClient = new ApolloClient({
|
||||||
|
cache,
|
||||||
|
link
|
||||||
|
});
|
||||||
|
|
||||||
|
return apolloClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default setupApi;
|
Loading…
Reference in a new issue