Skip to content

Commit 2b8df14

Browse files
committed
Jest testing work
1 parent 843bd7c commit 2b8df14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+883
-986
lines changed

jest-setup-wordpress-globals.js

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import Backbone from 'backbone';
77
import * as Mn from 'backbone.marionette';
88
import underscore from 'underscore';
99

10-
import Enzyme from 'enzyme';
11-
import Adapter from '@cfaester/enzyme-adapter-react-18';
12-
1310
import {
1411
combineReducers,
1512
registerStore,
@@ -41,4 +38,36 @@ global.Backbone.Marionette = Mn;
4138
// @see PodsInit.php
4239
global.PodsMn = global.Backbone.noConflict();
4340

44-
Enzyme.configure({ adapter: new Adapter() });
41+
/*let consoleSpyWarn;
42+
let consoleSpyError;
43+
44+
beforeAll(() => {
45+
consoleSpyWarn = jest.spyOn(global.console, 'warn').mockImplementation((message) => {
46+
if (!message.includes('findDOMNode is deprecated') && !message.includes('ReactDOMTestUtils.act')) {
47+
global.console.warn(message);
48+
}
49+
});
50+
consoleSpyError = jest.spyOn(global.console, 'error').mockImplementation((message) => {
51+
if (!message.includes('findDOMNode is deprecated') && !message.includes('ReactDOMTestUtils.act')) {
52+
global.console.error(message);
53+
}
54+
});
55+
});
56+
57+
afterAll(() => {
58+
consoleSpyWarn.mockRestore();
59+
consoleSpyError.mockRestore();
60+
});*/
61+
62+
/*const consoleError = console.error.bind(console);
63+
const consoleWarn = console.warn.bind(console);
64+
beforeAll(() => {
65+
console.error = (message, ...args) =>
66+
!message.toString().includes('findDOMNode is deprecated') && !message.toString().includes('ReactDOMTestUtils.act') && consoleError(message, args)
67+
console.warn = (message, ...args) =>
68+
!message.toString().includes('findDOMNode is deprecated') && !message.toString().includes('ReactDOMTestUtils.act') && consoleWarn(message, args)
69+
})
70+
afterAll(() => {
71+
console.error = consoleError
72+
console.warn = consoleWarn
73+
})*/

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ module.exports = {
2222
testMatch: [
2323
'**/test/*.js',
2424
],
25+
26+
errorOnDeprecated: false,
2527
};

0 commit comments

Comments
 (0)