From 152027a639998b2c404d2fabc41556b6bed15ce4 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Thu, 29 Mar 2018 16:44:24 -0700 Subject: [PATCH] Fix test warning spam --- ui/jest.config.js | 2 +- ui/test/setup.js | 22 ++++++++++++++++++++++ ui/test/setupTests.js | 4 ---- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 ui/test/setup.js delete mode 100644 ui/test/setupTests.js diff --git a/ui/jest.config.js b/ui/jest.config.js index 7115626da..879e568e5 100644 --- a/ui/jest.config.js +++ b/ui/jest.config.js @@ -8,7 +8,7 @@ module.exports = { ], modulePaths: ['', '/node_modules/'], moduleDirectories: ['src'], - setupFiles: ['/test/setupTests.js'], + setupFiles: ['/test/setup.js'], transform: { '^.+\\.tsx?$': 'ts-jest', '^.+\\.js$': 'babel-jest', diff --git a/ui/test/setup.js b/ui/test/setup.js new file mode 100644 index 000000000..c2f5f9a28 --- /dev/null +++ b/ui/test/setup.js @@ -0,0 +1,22 @@ +import {configure} from 'enzyme' +import React from 'react' + +import Adapter from 'enzyme-adapter-react-15' + +configure({adapter: new Adapter()}) + +/** + * Since React v15.5, there's a warning printed if you access `React.createClass` or `React.PropTypes` + * https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#new-deprecation-warnings + * + * `import * as React from 'react'` is required by Flowtype https://flow.org/en/docs/react/types/ , + * but the * causes both those deprecated getters to be called. + * This is particularly annoying in Jest since every test prints two useless warnings. + * + * This file can be used as a Jest setup file to simply delete those features of the `react` package. + * You don't need the deprecation warning. Your tests will simply fail if you're still using the old ways. + * https://facebook.github.io/jest/docs/en/configuration.html#setupfiles-array + */ + +delete React.createClass +delete React.PropTypes diff --git a/ui/test/setupTests.js b/ui/test/setupTests.js deleted file mode 100644 index 98e92fffb..000000000 --- a/ui/test/setupTests.js +++ /dev/null @@ -1,4 +0,0 @@ -import {configure} from 'enzyme' -import Adapter from 'enzyme-adapter-react-15' - -configure({adapter: new Adapter()})