mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
Start converting to jest
This commit is contained in:
parent
f2e01b1ca1
commit
36d1fde185
3
extension/jest.config.js
Normal file
3
extension/jest.config.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
setupFiles: ['<rootDir>/test/app/setup.js'],
|
||||||
|
};
|
|
@ -18,9 +18,9 @@
|
||||||
"docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:zalmoxisus/redux-devtools-extension gh-pages --force",
|
"docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:zalmoxisus/redux-devtools-extension gh-pages --force",
|
||||||
"clean": "rimraf build/ && rimraf dev/",
|
"clean": "rimraf build/ && rimraf dev/",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"test:app": "cross-env BABEL_ENV=test mocha --require test/app/setup.js test/app",
|
"test:app": "jest test/app",
|
||||||
"test:chrome": "mocha --require test/chrome/setup.js test/chrome",
|
"test:chrome": "jest test/chrome",
|
||||||
"test:electron": "mocha --require test/electron/setup.js test/electron && rimraf test/electron/tmp",
|
"test:electron": "jest test/electron && rimraf test/electron/tmp",
|
||||||
"test": "npm run test:app && npm run build:extension && npm run test:chrome && npm run test:electron"
|
"test": "npm run test:app && npm run build:extension && npm run test:chrome && npm run test:electron"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -43,7 +43,6 @@
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.1.0",
|
||||||
"bestzip": "^2.1.7",
|
"bestzip": "^2.1.7",
|
||||||
"chromedriver": "^2.35.0",
|
"chromedriver": "^2.35.0",
|
||||||
"co-mocha": "^1.1.3",
|
|
||||||
"copy-webpack-plugin": "^6.3.1",
|
"copy-webpack-plugin": "^6.3.1",
|
||||||
"cross-env": "^1.0.8",
|
"cross-env": "^1.0.8",
|
||||||
"electron": "^2.0.2",
|
"electron": "^2.0.2",
|
||||||
|
@ -51,11 +50,9 @@
|
||||||
"eslint": "^7.6.0",
|
"eslint": "^7.6.0",
|
||||||
"eslint-config-airbnb": "^0.1.0",
|
"eslint-config-airbnb": "^0.1.0",
|
||||||
"eslint-plugin-react": "^3.2.3",
|
"eslint-plugin-react": "^3.2.3",
|
||||||
"expect": "^1.20.1",
|
|
||||||
"file-loader": "^6.2.0",
|
"file-loader": "^6.2.0",
|
||||||
"gitbook-cli": "^2.3.0",
|
"gitbook-cli": "^2.3.0",
|
||||||
"jsdom": "^9.8.3",
|
"jest": "^26.2.2",
|
||||||
"mocha": "^3.1.2",
|
|
||||||
"pug-html-loader": "^1.1.5",
|
"pug-html-loader": "^1.1.5",
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"react-addons-test-utils": "^15.4.1",
|
"react-addons-test-utils": "^15.4.1",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import expect from 'expect';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { mount } from 'enzyme';
|
import { mount } from 'enzyme';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
@ -14,7 +13,7 @@ const component = mount(
|
||||||
|
|
||||||
describe('App container', () => {
|
describe('App container', () => {
|
||||||
it("should render inspector monitor's component", () => {
|
it("should render inspector monitor's component", () => {
|
||||||
expect(component.find('DevtoolsInspector').html()).toExist();
|
expect(component.find('DevtoolsInspector').html()).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain an empty action list', () => {
|
it('should contain an empty action list', () => {
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
import expect from 'expect';
|
|
||||||
import { insertScript, listenMessage } from '../../utils/inject';
|
import { insertScript, listenMessage } from '../../utils/inject';
|
||||||
import '../../../src/browser/extension/inject/pageScript';
|
import '../../../src/browser/extension/inject/pageScript';
|
||||||
|
|
||||||
describe('API', () => {
|
describe('API', () => {
|
||||||
it('should get window.__REDUX_DEVTOOLS_EXTENSION__ function', () => {
|
it('should get window.__REDUX_DEVTOOLS_EXTENSION__ function', () => {
|
||||||
expect(window.__REDUX_DEVTOOLS_EXTENSION__).toBeA('function');
|
expect(typeof window.__REDUX_DEVTOOLS_EXTENSION__).toBe('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should notify error', () => {
|
it('should notify error', () => {
|
||||||
const spy = expect.createSpy(() => {});
|
const mockFunc = jest.fn(() => {});
|
||||||
window.__REDUX_DEVTOOLS_EXTENSION__.notifyErrors(spy);
|
window.__REDUX_DEVTOOLS_EXTENSION__.notifyErrors(mockFunc);
|
||||||
insertScript('hi()');
|
insertScript('hi()');
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(mockFunc.mock.calls.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should open monitor', async () => {
|
it('should open monitor', async () => {
|
||||||
|
@ -38,7 +37,7 @@ describe('API', () => {
|
||||||
let message = await listenMessage(() => {
|
let message = await listenMessage(() => {
|
||||||
window.__REDUX_DEVTOOLS_EXTENSION__.send('hi');
|
window.__REDUX_DEVTOOLS_EXTENSION__.send('hi');
|
||||||
});
|
});
|
||||||
expect(message).toInclude({
|
expect(message).toMatchObject({
|
||||||
type: 'ACTION',
|
type: 'ACTION',
|
||||||
payload: undefined,
|
payload: undefined,
|
||||||
instanceId: 1,
|
instanceId: 1,
|
||||||
|
@ -54,7 +53,7 @@ describe('API', () => {
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(message).toInclude({
|
expect(message).toMatchObject({
|
||||||
type: 'ACTION',
|
type: 'ACTION',
|
||||||
payload: '{"counter":1}',
|
payload: '{"counter":1}',
|
||||||
instanceId: 1,
|
instanceId: 1,
|
||||||
|
@ -70,7 +69,7 @@ describe('API', () => {
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
expect(message).toInclude({
|
expect(message).toMatchObject({
|
||||||
type: 'ACTION',
|
type: 'ACTION',
|
||||||
payload: '{"counter":1}',
|
payload: '{"counter":1}',
|
||||||
instanceId: 1,
|
instanceId: 1,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import '@babel/polyfill';
|
import '@babel/polyfill';
|
||||||
import expect from 'expect';
|
|
||||||
import { createStore, compose } from 'redux';
|
import { createStore, compose } from 'redux';
|
||||||
import { insertScript, listenMessage } from '../../utils/inject';
|
import { insertScript, listenMessage } from '../../utils/inject';
|
||||||
import '../../../src/browser/extension/inject/pageScript';
|
import '../../../src/browser/extension/inject/pageScript';
|
||||||
|
@ -22,7 +21,7 @@ describe('Redux enhancer', () => {
|
||||||
counter,
|
counter,
|
||||||
window.__REDUX_DEVTOOLS_EXTENSION__()
|
window.__REDUX_DEVTOOLS_EXTENSION__()
|
||||||
);
|
);
|
||||||
expect(window.store).toBeA('object');
|
expect(typeof window.store).toBe('object');
|
||||||
});
|
});
|
||||||
expect(message.type).toBe('INIT_INSTANCE');
|
expect(message.type).toBe('INIT_INSTANCE');
|
||||||
expect(window.store.getState()).toBe(0);
|
expect(window.store.getState()).toBe(0);
|
||||||
|
@ -187,7 +186,7 @@ describe('Redux enhancer', () => {
|
||||||
serializeState: (key, value) => value,
|
serializeState: (key, value) => value,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
expect(window.store).toBeA('object');
|
expect(typeof window.store).toBe('object');
|
||||||
});
|
});
|
||||||
expect(message.type).toBe('INIT_INSTANCE');
|
expect(message.type).toBe('INIT_INSTANCE');
|
||||||
});
|
});
|
||||||
|
@ -197,7 +196,7 @@ describe('Redux enhancer', () => {
|
||||||
window.store = window.__REDUX_DEVTOOLS_EXTENSION__()(createStore)(
|
window.store = window.__REDUX_DEVTOOLS_EXTENSION__()(createStore)(
|
||||||
counter
|
counter
|
||||||
);
|
);
|
||||||
expect(window.store).toBeA('object');
|
expect(typeof window.store).toBe('object');
|
||||||
});
|
});
|
||||||
expect(message.type).toBe('INIT_INSTANCE');
|
expect(message.type).toBe('INIT_INSTANCE');
|
||||||
});
|
});
|
||||||
|
@ -210,7 +209,7 @@ describe('Redux enhancer', () => {
|
||||||
counter,
|
counter,
|
||||||
compose(testEnhancer, window.__REDUX_DEVTOOLS_EXTENSION__())
|
compose(testEnhancer, window.__REDUX_DEVTOOLS_EXTENSION__())
|
||||||
);
|
);
|
||||||
expect(window.store).toBeA('object');
|
expect(typeof window.store).toBe('object');
|
||||||
});
|
});
|
||||||
expect(message.type).toBe('INIT_INSTANCE');
|
expect(message.type).toBe('INIT_INSTANCE');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
require('@babel/register')();
|
// require('@babel/register')();
|
||||||
require('@babel/polyfill');
|
require('@babel/polyfill');
|
||||||
global.chrome = require('sinon-chrome');
|
global.chrome = require('sinon-chrome');
|
||||||
var jsdom = require('jsdom').jsdom;
|
// var jsdom = require('jsdom').jsdom;
|
||||||
|
//
|
||||||
var exposedProperties = ['window', 'navigator', 'document'];
|
// var exposedProperties = ['window', 'navigator', 'document'];
|
||||||
|
//
|
||||||
global.document = jsdom('');
|
// global.document = jsdom('');
|
||||||
global.window = document.defaultView;
|
// global.window = document.defaultView;
|
||||||
Object.keys(document.defaultView).forEach((property) => {
|
// Object.keys(document.defaultView).forEach((property) => {
|
||||||
if (typeof global[property] === 'undefined') {
|
// if (typeof global[property] === 'undefined') {
|
||||||
exposedProperties.push(property);
|
// exposedProperties.push(property);
|
||||||
global[property] = document.defaultView[property];
|
// global[property] = document.defaultView[property];
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
global.navigator = {
|
// global.navigator = {
|
||||||
userAgent: 'gecko',
|
// userAgent: 'gecko',
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
global.document.createRange = function () {
|
// global.document.createRange = function () {
|
||||||
return {
|
// return {
|
||||||
setEnd: function () {},
|
// setEnd: function () {},
|
||||||
setStart: function () {},
|
// setStart: function () {},
|
||||||
getBoundingClientRect: function () {
|
// getBoundingClientRect: function () {
|
||||||
return { right: 0 };
|
// return { right: 0 };
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
documentRef = document;
|
// documentRef = document;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import webdriver from 'selenium-webdriver';
|
import webdriver from 'selenium-webdriver';
|
||||||
import expect from 'expect';
|
|
||||||
import chromedriver from 'chromedriver';
|
import chromedriver from 'chromedriver';
|
||||||
import { switchMonitorTests, delay } from '../utils/e2e';
|
import { switchMonitorTests, delay } from '../utils/e2e';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import webdriver from 'selenium-webdriver';
|
import webdriver from 'selenium-webdriver';
|
||||||
import electronPath from 'electron';
|
import electronPath from 'electron';
|
||||||
import expect from 'expect';
|
|
||||||
import chromedriver from 'chromedriver';
|
import chromedriver from 'chromedriver';
|
||||||
import { switchMonitorTests, delay } from '../utils/e2e';
|
import { switchMonitorTests, delay } from '../utils/e2e';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import '@babel/polyfill';
|
import '@babel/polyfill';
|
||||||
import expect from 'expect';
|
|
||||||
import { bigArray, bigString, circularData } from './data';
|
import { bigArray, bigString, circularData } from './data';
|
||||||
import { listenMessage } from '../utils/inject';
|
import { listenMessage } from '../utils/inject';
|
||||||
import '../../src/browser/extension/inject/pageScript';
|
import '../../src/browser/extension/inject/pageScript';
|
||||||
|
|
2138
extension/yarn.lock
2138
extension/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user