refactor(react): upgrade @testing-library/react (#1905)

* refactor(react): upgrade @testing-library/react

@testing-library/react v.9 doesn't require clean()

close #1855

* chore(react): remove cleanup

* refactor(react): change testingLibraryVersion 8.0.5 to 9.2.0

* refactor(react): update spec
This commit is contained in:
tyankatsu 2019-10-15 21:59:32 +09:00 committed by Jack Hsu
parent 6160cc2324
commit c732fd2f21
8 changed files with 52 additions and 26 deletions

1
.gitignore vendored
View File

@ -10,3 +10,4 @@ tmp
*.log *.log
.ng_pkg_build .ng_pkg_build
jest.debug.config.js jest.debug.config.js
.tool-versions

View File

@ -58,7 +58,7 @@
"@ngrx/store": "8.3.0", "@ngrx/store": "8.3.0",
"@ngrx/store-devtools": "8.3.0", "@ngrx/store-devtools": "8.3.0",
"@schematics/angular": "8.3.3", "@schematics/angular": "8.3.3",
"@testing-library/react": "8.0.5", "@testing-library/react": "9.2.0",
"@types/express": "4.17.0", "@types/express": "4.17.0",
"@types/jasmine": "~2.8.6", "@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",

View File

@ -1,11 +1,9 @@
import React from 'react'; import React from 'react';
import { render, cleanup } from '@testing-library/react'; import { render } from '@testing-library/react';
import Index from '../pages/index'; import Index from '../pages/index';
describe('Index', () => { describe('Index', () => {
afterEach(cleanup);
it('should render successfully', () => { it('should render successfully', () => {
const { baseElement } = render(<Index />); const { baseElement } = render(<Index />);
expect(baseElement).toBeTruthy(); expect(baseElement).toBeTruthy();

View File

@ -88,7 +88,7 @@ describe('Update 8-0-0', () => {
'styled-components': '4.3.2' 'styled-components': '4.3.2'
}, },
devDependencies: { devDependencies: {
'@testing-library/react': '8.0.5', '@testing-library/react': '9.2.0',
'@types/react': '16.8.23', '@types/react': '16.8.23',
'@types/react-dom': '16.8.5', '@types/react-dom': '16.8.5',
'@types/styled-components': '4.1.18' '@types/styled-components': '4.1.18'

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { render, cleanup } from '@testing-library/react'; import { render } from '@testing-library/react';
<% if (routing) { %> <% if (routing) { %>
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from 'react-router-dom';
<% } %> <% } %>
@ -7,8 +7,6 @@ import { BrowserRouter } from 'react-router-dom';
import App from './app'; import App from './app';
describe('App', () => { describe('App', () => {
afterEach(cleanup);
it('should render successfully', () => { it('should render successfully', () => {
<% if (routing) { %> <% if (routing) { %>
const { baseElement } = render(<BrowserRouter><App /></BrowserRouter>); const { baseElement } = render(<BrowserRouter><App /></BrowserRouter>);

View File

@ -1,11 +1,9 @@
import React from 'react'; import React from 'react';
import { render, cleanup } from '@testing-library/react'; import { render } from '@testing-library/react';
import <%= className %> from './<%= fileName %>'; import <%= className %> from './<%= fileName %>';
describe(' <%= className %>', () => { describe(' <%= className %>', () => {
afterEach(cleanup);
it('should render successfully', () => { it('should render successfully', () => {
const { baseElement } = render(< <%= className %> />); const { baseElement } = render(< <%= className %> />);
expect(baseElement).toBeTruthy(); expect(baseElement).toBeTruthy();

View File

@ -7,7 +7,7 @@ export const emotionVersion = '10.0.14';
export const domTypesVersion = '16.8.5'; export const domTypesVersion = '16.8.5';
export const reactRouterVersion = '5.0.1'; export const reactRouterVersion = '5.0.1';
export const reactRouterDomVersion = '4.3.5'; export const reactRouterDomVersion = '4.3.5';
export const testingLibraryVersion = '8.0.5'; export const testingLibraryVersion = '9.2.0';
export const babelPresetReactVersion = '7.0.0'; export const babelPresetReactVersion = '7.0.0';
export const reduxStarterKitVersion = '0.7.0'; export const reduxStarterKitVersion = '0.7.0';
export const reactReduxVersion = '7.1.1'; export const reactReduxVersion = '7.1.1';

View File

@ -1184,13 +1184,20 @@
dependencies: dependencies:
regenerator-runtime "^0.13.2" regenerator-runtime "^0.13.2"
"@babel/runtime@^7.1.2", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5": "@babel/runtime@^7.1.2", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.5":
version "7.6.0" version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.0.tgz#4fc1d642a9fd0299754e8b5de62c631cf5568205" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.0.tgz#4fc1d642a9fd0299754e8b5de62c631cf5568205"
integrity sha512-89eSBLJsxNxOERC0Op4vd+0Bqm6wRMqMbFtV3i0/fbaWw/mJ8Q3eBvgX0G4SyrOOLCtbu98HspF8o09MRT+KzQ== integrity sha512-89eSBLJsxNxOERC0Op4vd+0Bqm6wRMqMbFtV3i0/fbaWw/mJ8Q3eBvgX0G4SyrOOLCtbu98HspF8o09MRT+KzQ==
dependencies: dependencies:
regenerator-runtime "^0.13.2" regenerator-runtime "^0.13.2"
"@babel/runtime@^7.5.5", "@babel/runtime@^7.6.0":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.2.tgz#c3d6e41b304ef10dcf13777a33e7694ec4a9a6dd"
integrity sha512-EXxN64agfUqqIGeEjI5dL5z0Sw0ZwWo1mLTi4mQowCZ42O59b7DRpZAnTC6OqdF28wMBMFKNb/4uFGrVaigSpg==
dependencies:
regenerator-runtime "^0.13.2"
"@babel/template@^7.1.0", "@babel/template@^7.4.0", "@babel/template@^7.4.4", "@babel/template@^7.6.0": "@babel/template@^7.1.0", "@babel/template@^7.4.0", "@babel/template@^7.4.4", "@babel/template@^7.6.0":
version "7.6.0" version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6"
@ -1660,24 +1667,26 @@
dependencies: dependencies:
defer-to-connect "^1.0.1" defer-to-connect "^1.0.1"
"@testing-library/dom@^5.5.4": "@testing-library/dom@^6.3.0":
version "5.6.1" version "6.5.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-5.6.1.tgz#705a1cb4a039b877c1e69e916824038e837ab637" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-6.5.0.tgz#9419fec57a544917bd5e398d40826425be50ee0a"
integrity sha512-Y1T2bjtvQMewffn1CJ28kpgnuvPYKsBcZMagEH0ppfEMZPDc8AkkEnTk4smrGZKw0cblNB3lhM2FMnpfLExlHg== integrity sha512-3lQx248dhJzvV2a76F1VaqehX+iquSVVW27caDaLoQZdUHEZjB370n7FO2WoYwOQQ7NB10AvfPhrARYnNgvf1g==
dependencies: dependencies:
"@babel/runtime" "^7.5.5" "@babel/runtime" "^7.5.5"
"@sheerun/mutationobserver-shim" "^0.3.2" "@sheerun/mutationobserver-shim" "^0.3.2"
"@types/testing-library__dom" "^6.0.0"
aria-query "3.0.0" aria-query "3.0.0"
pretty-format "^24.8.0" pretty-format "^24.8.0"
wait-for-expect "^1.2.0" wait-for-expect "^1.3.0"
"@testing-library/react@8.0.5": "@testing-library/react@9.2.0":
version "8.0.5" version "9.2.0"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-8.0.5.tgz#2301011a8c5567eba59691860df19a3cfc9d7425" resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-9.2.0.tgz#143ad2d96b03c3c334e47aaf33cc2c9b7d007123"
integrity sha512-2EzVi7HjUUF8gKzB4s+oCJ1+F4VOrphO+DlUO6Ptgtcz1ko4J2zqnr0t7g+T7uedXXjJ0wdq70zQMhJXP3w37A== integrity sha512-Hr87KZflfI+vPZjgyzBKQHolQHiXGU5aTGjQSCJdH/yGPbm+IzrvuWPS97GD3RUH3rSS1IXq1e2Sn8Hmyw2ctA==
dependencies: dependencies:
"@babel/runtime" "^7.5.4" "@babel/runtime" "^7.6.0"
"@testing-library/dom" "^5.5.4" "@testing-library/dom" "^6.3.0"
"@types/testing-library__react" "^9.1.0"
"@types/anymatch@*": "@types/anymatch@*":
version "1.3.1" version "1.3.1"
@ -1887,6 +1896,13 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
"@types/react-dom@*":
version "16.9.1"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.1.tgz#79206237cba9532a9f870b1cd5428bef6b66378c"
integrity sha512-1S/akvkKr63qIUWVu5IKYou2P9fHLb/P2VAwyxVV85JGaGZTcUniMiTuIqM3lXFB25ej6h+CYEQ27ERVwi6eGA==
dependencies:
"@types/react" "*"
"@types/react-dom@^16.8.5": "@types/react-dom@^16.8.5":
version "16.9.0" version "16.9.0"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.0.tgz#ba6ddb00bf5de700b0eb91daa452081ffccbfdea" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.0.tgz#ba6ddb00bf5de700b0eb91daa452081ffccbfdea"
@ -1949,6 +1965,21 @@
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370" resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ== integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==
"@types/testing-library__dom@*", "@types/testing-library__dom@^6.0.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-6.5.0.tgz#ae67c9cdac1bb20dd210bbf3decac9da16981f84"
integrity sha512-VgfB4rXWA7jAHbmTM4yAZeaxsh/YBd0qIuOZ7v1+17V6poO0KxdH6bq95O2+EiGwuAkS7Lcm1gh5sI7gUjAkxw==
dependencies:
pretty-format "^24.3.0"
"@types/testing-library__react@^9.1.0":
version "9.1.1"
resolved "https://registry.yarnpkg.com/@types/testing-library__react/-/testing-library__react-9.1.1.tgz#4bcb8bba54b07fbb6c084f2f00e7f9410e587c10"
integrity sha512-8/toTJaIlS3BC7JrK2ElTnbjH8tmFP7atdL2ZsIa1JDmH9RKSm/7Wp5oMDJzXoWr988Mv7ym/XZ8LRglyoGCGw==
dependencies:
"@types/react-dom" "*"
"@types/testing-library__dom" "*"
"@types/uglify-js@*": "@types/uglify-js@*":
version "3.0.4" version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
@ -12452,7 +12483,7 @@ pretty-error@^2.0.2:
renderkid "^2.0.1" renderkid "^2.0.1"
utila "~0.4" utila "~0.4"
pretty-format@^24.8.0, pretty-format@^24.9.0: pretty-format@^24.3.0, pretty-format@^24.8.0, pretty-format@^24.9.0:
version "24.9.0" version "24.9.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.9.0.tgz#12fac31b37019a4eea3c11aa9a959eb7628aa7c9"
integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA== integrity sha512-00ZMZUiHaJrNfk33guavqgvfJS30sLYf0f8+Srklv0AMPodGGHcoHgksZ3OThYnIvOd+8yMCn0YiEOogjlgsnA==
@ -15669,7 +15700,7 @@ w3c-xmlserializer@^1.0.1:
webidl-conversions "^4.0.2" webidl-conversions "^4.0.2"
xml-name-validator "^3.0.0" xml-name-validator "^3.0.0"
wait-for-expect@^1.2.0: wait-for-expect@^1.3.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-1.3.0.tgz#65241ce355425f907f5d127bdb5e72c412ff830c" resolved "https://registry.yarnpkg.com/wait-for-expect/-/wait-for-expect-1.3.0.tgz#65241ce355425f907f5d127bdb5e72c412ff830c"
integrity sha512-8fJU7jiA96HfGPt+P/UilelSAZfhMBJ52YhKzlmZQvKEZU2EcD1GQ0yqGB6liLdHjYtYAoGVigYwdxr5rktvzA== integrity sha512-8fJU7jiA96HfGPt+P/UilelSAZfhMBJ52YhKzlmZQvKEZU2EcD1GQ0yqGB6liLdHjYtYAoGVigYwdxr5rktvzA==