Skip to content

Commit bb10988

Browse files
fix: failing test in App.test.js (#296)
1 parent 147e405 commit bb10988

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/components/App.test.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import App from './App';
4-
import * as utils from '../utils/buildEventSource';
5-
6-
const buildEventSourceSpy = jest.spyOn(utils, 'buildEventSource');
7-
8-
buildEventSourceSpy.mockReturnValue({
9-
CLOSED: 0,
10-
CONNECTING: 0,
11-
OPEN: 0,
12-
dispatchEvent(event) {
13-
return false;
14-
},
15-
onerror: jest.fn(),
16-
onmessage: jest.fn(),
17-
onopen: jest.fn(),
18-
readyState: 0,
19-
url: '',
20-
withCredentials: false,
21-
addEventListener: jest.fn(),
22-
close: jest.fn(),
23-
removeEventListener: jest.fn()
24-
});
254

265
it('renders without crashing', () => {
276
const div = document.createElement('div');

src/setupTests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
import '@testing-library/jest-dom';
2+
3+
Object.defineProperty(window, 'EventSource', {
4+
writable: true,
5+
value: jest.fn().mockImplementation(() => ({
6+
CLOSED: 0,
7+
CONNECTING: 0,
8+
OPEN: 0,
9+
dispatchEvent(event) {
10+
return false;
11+
},
12+
onerror: jest.fn(),
13+
onmessage: jest.fn(),
14+
onopen: jest.fn(),
15+
readyState: 0,
16+
url: '',
17+
withCredentials: false,
18+
addEventListener: jest.fn(),
19+
close: jest.fn(),
20+
removeEventListener: jest.fn()
21+
}))
22+
});

0 commit comments

Comments
 (0)