This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { graphql, GraphQLContext, GraphQLRequest, ResponseResolver } from 'msw'; | |
import { api } from '../../../services/graphqlApi.generated'; | |
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; | |
export type Scalars = { | |
String: string; | |
}; | |
export type GetSomethingQueryVariables = Exact<{ | |
id: Scalars['String']; | |
}>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { waitFor } from '@testing-library/react'; | |
import { server } from '../../../../test/mocks/server'; | |
import { generateSomething } from '../../test/fixtures/something.fixture'; | |
import { renderWrapper } from '../../test/helpers/renderWrapper'; | |
import { AnyComponent } from './AnyComponent'; | |
describe('Rendering any component with `renderWrapper`', () => { | |
it('should wait for msw resolver to execute', async () => { | |
const getSomethingResolver: Parameters<typeof mockGetSomethingQuery>[0] = jest.fn( | |
(_req, res, ctx) => res(ctx.data({ getSomething: generateSomething()})), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"generate-gql": "graphql-codegen --config codegen.yml", | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
overwrite: true | |
schema: 'https://{{LOCAL_API_ENDPOINT}}:3443/graphql' | |
generates: | |
src/services/graphqlApi.generated.ts: | |
documents: 'src/services/graphql/*.graphql' | |
plugins: | |
- 'typescript' | |
- 'typescript-operations' | |
- 'typescript-msw' | |
- typescript-rtk-query: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uniqSort = function(arr) { | |
const bread = {}; | |
const result = [arr[0]]; | |
for (let i = 1; i < arr.length; i++) { | |
if(!bread[arr[i]] { | |
result.push(arr[i]); | |
bread[arr[i]] = true; | |
} | |
} | |
return result.sort((a,b) => a - b); |