Skip to content

Commit

Permalink
Fix react testling library context errors (#2903)
Browse files Browse the repository at this point in the history
* upgrades testing-library packages to latest allowed @ React 17
* updates @graphiql/react test files for new testing-library version
* updates tests to remove act() warnings
• rewrites some tests to remove old prop values and use new ones
  • Loading branch information
jonathanawesome authored Nov 13, 2022
1 parent eff4fd6 commit a1439db
Show file tree
Hide file tree
Showing 9 changed files with 1,011 additions and 729 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@cypress/webpack-preprocessor": "^5.5.0",
"@manypkg/get-packages": "^1.1.3",
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
"@testing-library/jest-dom": "^5.4.0",
"@testing-library/jest-dom": "5.16.5",
"@types/aws-serverless-express": "^3.3.3",
"@types/codemirror": "^0.0.90",
"@types/express": "^4.17.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"set-value": "^4.1.0"
},
"devDependencies": {
"@testing-library/react": "9.4.1",
"@testing-library/react": "12.1.5",
"@types/codemirror": "^5.60.5",
"@types/set-value": "^4.0.1",
"@vitejs/plugin-react": "^1.3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
// @ts-expect-error
fireEvent,
render,
} from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import { GraphQLString, GraphQLObjectType, Kind } from 'graphql';

import { ExplorerContext, ExplorerFieldDef } from '../../context';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
// @ts-expect-error
fireEvent,
render,
} from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import {
GraphQLBoolean,
GraphQLEnumType,
Expand Down Expand Up @@ -89,7 +85,7 @@ describe('TypeDocumentation', () => {
const title = container.querySelector(
'.graphiql-doc-explorer-section-title',
);
title.removeChild(title.childNodes[0]);
title?.removeChild(title?.childNodes[0]);
expect(title).toHaveTextContent('Possible Types');
});

Expand All @@ -100,7 +96,7 @@ describe('TypeDocumentation', () => {
const title = container.querySelector(
'.graphiql-doc-explorer-section-title',
);
title.removeChild(title.childNodes[0]);
title?.removeChild(title?.childNodes[0]);
expect(title).toHaveTextContent('Enum Values');
const enums = container.querySelectorAll(
'.graphiql-doc-explorer-enum-value',
Expand All @@ -119,7 +115,7 @@ describe('TypeDocumentation', () => {
const title = container.querySelector(
'.graphiql-doc-explorer-section-title',
);
title.removeChild(title.childNodes[0]);
title?.removeChild(title?.childNodes[0]);
expect(title).toHaveTextContent('Enum Values');

let enums = container.querySelectorAll('.graphiql-doc-explorer-enum-value');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
// @ts-expect-error
fireEvent,
render,
} from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import { GraphQLNonNull, GraphQLList, GraphQLString } from 'graphql';
import { ComponentProps } from 'react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
// @ts-expect-error
fireEvent,
render,
} from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import { ComponentProps } from 'react';
import { formatQuery, HistoryItem } from '../components';
import { HistoryContextProvider } from '../context';
Expand Down
6 changes: 3 additions & 3 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.4.0",
"@testing-library/react": "9.4.1",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@types/codemirror": "^5.60.5",
"@types/markdown-it": "^12.2.3",
"@types/node": "^14.14.22",
"@types/testing-library__jest-dom": "^5.0.1",
"@types/testing-library__jest-dom": "5.14.5",
"babel-loader": "^8.1.0",
"babel-plugin-macros": "^2.8.0",
"cross-env": "^7.0.2",
Expand Down
Loading

0 comments on commit a1439db

Please sign in to comment.