{"size": 1847, "ext": "js", "max_stars_repo_path": "src/test/setupTests.js", "max_stars_repo_name": "react-custom-projects/mocha-chai-testing", "max_stars_repo_stars_event_min_datetime": "2020-04-12T18:48:49.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-23T11:21:31.000Z", "max_issues_repo_path": "src/test/setupTests.js", "max_issues_repo_name": "react-custom-projects/mocha-chai-testing", "max_issues_repo_issues_event_min_datetime": "2019-10-31T13:01:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-23T06:24:23.000Z", "max_forks_repo_path": "src/test/setupTests.js", "max_forks_repo_name": "react-custom-projects/mocha-chai-testing", "max_forks_repo_forks_event_min_datetime": "2020-04-12T18:48:55.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-24T00:21:07.000Z"}
{"max_stars_count": 5, "max_issues_count": 21, "max_forks_count": 3, "avg_line_length": 30.7833333333, "max_line_length": 112, "alphanum_fraction": 0.7363291825}
//redux mock store
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
//sinon
import sinon from 'sinon';
//enzyme
import { mount, render, shallow, ShallowWrapper, configure } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import chaiEnzyme from 'chai-enzyme';
//chai
import chai, { expect } from 'chai';
import chaiReduxMockStore from 'chai-redux-mock-store';
//mocha
import { describe, beforeEach, afterEach, before, after, it } from 'mocha';
//js dom setup
require('jsdom-global')();

const middleWares = [thunk],
	mockStore = configureStore(middleWares),
	createState =
		({ initialState, reducer }) =>
		(actions) =>
			actions.reduce(reducer, initialState),
	mockedStore = ({ initialState, reducer }) => mockStore(createState({ initialState, reducer }));

//enzyme configurations
configure({
	adapter: new Adapter(),
});

//chai assertion for enzyme
chai.use(chaiEnzyme());
//chai assertion for redux mock store
chai.use(chaiReduxMockStore);

/**************** set global functions ****************/
//mock store
global.mockedStore = mockedStore;
//sinon
global.sinon = sinon;
//chai
global.expect = expect;
//mocha
global.describe = describe;
global.beforeEach = beforeEach;
global.afterEach = afterEach;
global.before = before;
global.after = after;
global.it = it;
//enzyme
/* renders the whole DOM tree and gives you jQuery-like API to access DOM elements
inside this tree, simulate events and read text content. */
global.mount = mount;
/* returns a string with rendered HTML code, similar to the renderToString() method
from react-dom. It’s useful when you need to test HTML output. For example, a component that renders Markdown */
global.render = render;
// renders only the component itself without its children
global.shallow = shallow;
global.ShallowWrapper = ShallowWrapper;
