mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 00:19:55 +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",
|
||||
"clean": "rimraf build/ && rimraf dev/",
|
||||
"lint": "eslint .",
|
||||
"test:app": "cross-env BABEL_ENV=test mocha --require test/app/setup.js test/app",
|
||||
"test:chrome": "mocha --require test/chrome/setup.js test/chrome",
|
||||
"test:electron": "mocha --require test/electron/setup.js test/electron && rimraf test/electron/tmp",
|
||||
"test:app": "jest test/app",
|
||||
"test:chrome": "jest test/chrome",
|
||||
"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"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -43,7 +43,6 @@
|
|||
"babel-loader": "^8.1.0",
|
||||
"bestzip": "^2.1.7",
|
||||
"chromedriver": "^2.35.0",
|
||||
"co-mocha": "^1.1.3",
|
||||
"copy-webpack-plugin": "^6.3.1",
|
||||
"cross-env": "^1.0.8",
|
||||
"electron": "^2.0.2",
|
||||
|
@ -51,11 +50,9 @@
|
|||
"eslint": "^7.6.0",
|
||||
"eslint-config-airbnb": "^0.1.0",
|
||||
"eslint-plugin-react": "^3.2.3",
|
||||
"expect": "^1.20.1",
|
||||
"file-loader": "^6.2.0",
|
||||
"gitbook-cli": "^2.3.0",
|
||||
"jsdom": "^9.8.3",
|
||||
"mocha": "^3.1.2",
|
||||
"jest": "^26.2.2",
|
||||
"pug-html-loader": "^1.1.5",
|
||||
"raw-loader": "^0.5.1",
|
||||
"react-addons-test-utils": "^15.4.1",
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import expect from 'expect';
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { Provider } from 'react-redux';
|
||||
|
@ -14,7 +13,7 @@ const component = mount(
|
|||
|
||||
describe('App container', () => {
|
||||
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', () => {
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import expect from 'expect';
|
||||
import { insertScript, listenMessage } from '../../utils/inject';
|
||||
import '../../../src/browser/extension/inject/pageScript';
|
||||
|
||||
describe('API', () => {
|
||||
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', () => {
|
||||
const spy = expect.createSpy(() => {});
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__.notifyErrors(spy);
|
||||
const mockFunc = jest.fn(() => {});
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__.notifyErrors(mockFunc);
|
||||
insertScript('hi()');
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(mockFunc.mock.calls.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('should open monitor', async () => {
|
||||
|
@ -38,7 +37,7 @@ describe('API', () => {
|
|||
let message = await listenMessage(() => {
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__.send('hi');
|
||||
});
|
||||
expect(message).toInclude({
|
||||
expect(message).toMatchObject({
|
||||
type: 'ACTION',
|
||||
payload: undefined,
|
||||
instanceId: 1,
|
||||
|
@ -54,7 +53,7 @@ describe('API', () => {
|
|||
1
|
||||
);
|
||||
});
|
||||
expect(message).toInclude({
|
||||
expect(message).toMatchObject({
|
||||
type: 'ACTION',
|
||||
payload: '{"counter":1}',
|
||||
instanceId: 1,
|
||||
|
@ -70,7 +69,7 @@ describe('API', () => {
|
|||
1
|
||||
);
|
||||
});
|
||||
expect(message).toInclude({
|
||||
expect(message).toMatchObject({
|
||||
type: 'ACTION',
|
||||
payload: '{"counter":1}',
|
||||
instanceId: 1,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import '@babel/polyfill';
|
||||
import expect from 'expect';
|
||||
import { createStore, compose } from 'redux';
|
||||
import { insertScript, listenMessage } from '../../utils/inject';
|
||||
import '../../../src/browser/extension/inject/pageScript';
|
||||
|
@ -22,7 +21,7 @@ describe('Redux enhancer', () => {
|
|||
counter,
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__()
|
||||
);
|
||||
expect(window.store).toBeA('object');
|
||||
expect(typeof window.store).toBe('object');
|
||||
});
|
||||
expect(message.type).toBe('INIT_INSTANCE');
|
||||
expect(window.store.getState()).toBe(0);
|
||||
|
@ -187,7 +186,7 @@ describe('Redux enhancer', () => {
|
|||
serializeState: (key, value) => value,
|
||||
})
|
||||
);
|
||||
expect(window.store).toBeA('object');
|
||||
expect(typeof window.store).toBe('object');
|
||||
});
|
||||
expect(message.type).toBe('INIT_INSTANCE');
|
||||
});
|
||||
|
@ -197,7 +196,7 @@ describe('Redux enhancer', () => {
|
|||
window.store = window.__REDUX_DEVTOOLS_EXTENSION__()(createStore)(
|
||||
counter
|
||||
);
|
||||
expect(window.store).toBeA('object');
|
||||
expect(typeof window.store).toBe('object');
|
||||
});
|
||||
expect(message.type).toBe('INIT_INSTANCE');
|
||||
});
|
||||
|
@ -210,7 +209,7 @@ describe('Redux enhancer', () => {
|
|||
counter,
|
||||
compose(testEnhancer, window.__REDUX_DEVTOOLS_EXTENSION__())
|
||||
);
|
||||
expect(window.store).toBeA('object');
|
||||
expect(typeof window.store).toBe('object');
|
||||
});
|
||||
expect(message.type).toBe('INIT_INSTANCE');
|
||||
});
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
require('@babel/register')();
|
||||
// require('@babel/register')();
|
||||
require('@babel/polyfill');
|
||||
global.chrome = require('sinon-chrome');
|
||||
var jsdom = require('jsdom').jsdom;
|
||||
|
||||
var exposedProperties = ['window', 'navigator', 'document'];
|
||||
|
||||
global.document = jsdom('');
|
||||
global.window = document.defaultView;
|
||||
Object.keys(document.defaultView).forEach((property) => {
|
||||
if (typeof global[property] === 'undefined') {
|
||||
exposedProperties.push(property);
|
||||
global[property] = document.defaultView[property];
|
||||
}
|
||||
});
|
||||
|
||||
global.navigator = {
|
||||
userAgent: 'gecko',
|
||||
};
|
||||
|
||||
global.document.createRange = function () {
|
||||
return {
|
||||
setEnd: function () {},
|
||||
setStart: function () {},
|
||||
getBoundingClientRect: function () {
|
||||
return { right: 0 };
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
documentRef = document;
|
||||
// var jsdom = require('jsdom').jsdom;
|
||||
//
|
||||
// var exposedProperties = ['window', 'navigator', 'document'];
|
||||
//
|
||||
// global.document = jsdom('');
|
||||
// global.window = document.defaultView;
|
||||
// Object.keys(document.defaultView).forEach((property) => {
|
||||
// if (typeof global[property] === 'undefined') {
|
||||
// exposedProperties.push(property);
|
||||
// global[property] = document.defaultView[property];
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// global.navigator = {
|
||||
// userAgent: 'gecko',
|
||||
// };
|
||||
//
|
||||
// global.document.createRange = function () {
|
||||
// return {
|
||||
// setEnd: function () {},
|
||||
// setStart: function () {},
|
||||
// getBoundingClientRect: function () {
|
||||
// return { right: 0 };
|
||||
// },
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// documentRef = document;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { resolve } from 'path';
|
||||
import webdriver from 'selenium-webdriver';
|
||||
import expect from 'expect';
|
||||
import chromedriver from 'chromedriver';
|
||||
import { switchMonitorTests, delay } from '../utils/e2e';
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { join } from 'path';
|
||||
import webdriver from 'selenium-webdriver';
|
||||
import electronPath from 'electron';
|
||||
import expect from 'expect';
|
||||
import chromedriver from 'chromedriver';
|
||||
import { switchMonitorTests, delay } from '../utils/e2e';
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import '@babel/polyfill';
|
||||
import expect from 'expect';
|
||||
import { bigArray, bigString, circularData } from './data';
|
||||
import { listenMessage } from '../utils/inject';
|
||||
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