Code repository for an awesome course on React and Redux. See here
stephengrider / advancedreduxcode Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Code repository for an awesome course on React and Redux. See here
"before each" hook for "has the correct class": TypeError: Cannot convert undefined or null to object at Function.from (native) at _toConsumableArray (src/reducers/country_reducer.js:22:182) at exports.default (src/reducers/country_reducer.js:8:7) at combination (node_modules/redux/lib/combineReducers.js:132:29) at dispatch ---------------------------etc
Error Shows When Run Test cases of sign up page (npm run test -- --watch
)
How to Convert these program into Server Side Rendering for Increase Page Load And Server Down Problem
in the singin.js file when submitting the form console.log(email, password ) the result is undefined,undefined
the server side program requires config.js
Your test code wasn't passing so I had to do some research to get it to work. One thing I found was that test_helper.js might need to be updated to use ReactTestUtils instead of TestUtils.
So the following changes to test_utils.js:
import ReactTestUtils from 'react-dom/test-utils';
in renderComponent:
const componentInstance = ReactTestUtils.renderIntoDocument(
in build helper for simulating events:
$.fn.simulate = function(eventName, value) {
,,,
ReactTestUtils.SimulateeventName;
};
I have a query regarding the way to add ‘redux Thunk’ to the test_helper.js you explain and demonstrate in your videos.
Your original test_helper code has been tweaked to add redux thunk.
Having used ‘Redux Thunk’ in my project as demonstrated in another of your videos, I encountered an error in my tests due to them being wrapped by the ‘dispatch’ function in the action file.
MY attempt at changing test_helpers.js is below.
This produces a raft of abandoned promise error messages throughout the test result.
Please can you suggest a way to resolve this, or am I better off using Jest or Enzyme instead when using Redux Thunk?
Thanks in advance
`[I added these at top of script]
import { createStore, applyMiddleware } from 'redux';
import reduxThunk from 'redux-thunk';
[the updated function]
function renderComponent(ComponentClass, props = {}, state = {}) {
const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);
const componentInstance = TestUtils.renderIntoDocument(
<Provider store={createStoreWithMiddleware(reducers, state)}>
<ComponentClass {...props} />
);
return $(ReactDOM.findDOMNode(componentInstance));
}`
You forgot to add a unique "key" prop to the component.
Here - AdvancedReduxCode/middlewares/src/components/user_list.js
renderUser(user) {
return (
<div className="card card-block" **key** >
<h4 className="card-title">{user.name}</h4>
<p className="card-text">{user.company.name}</p>
<a className="btn btn-primary" href={user.website}>Website</a>
</div>
);
I recently enrolled in the Advanced React and Redux 2018 course, and tried to run the sample code. But 6 of the tests are failing.
I have attached the error log below, it's very verbose. I assume one can reproduce it easily instead.
Steps to reproduce:
/testing
foldernpm install
npm test
Full error message (sorry ><)
FAIL src/tests/integrations.test.js
● Console
console.error node_modules/fbjs/lib/warning.js:33
Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.
in Link (at App.js:25)
in li (at App.js:24)
in ul (at App.js:23)
in div (at App.js:37)
in App (created by Connect(App))
in Connect(App) (at integrations.test.js:22)
in Provider (at Root.js:14)
in Unknown (created by WrapperComponent)
in WrapperComponent
console.error node_modules/react-dom/cjs/react-dom.development.js:9643
The above error occurred in the <Route> component:
in Route (at App.js:40)
in div (at App.js:37)
in App (created by Connect(App))
in Connect(App) (at integrations.test.js:22)
in Provider (at Root.js:14)
in Unknown (created by WrapperComponent)
in WrapperComponent
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
● can fetch a list of comments and display them
Invariant Violation: You should not use <Route> or withRouter() outside a <Router>
at invariant (node_modules/invariant/invariant.js:40:15)
at Route.computeMatch (node_modules/react-router/Route.js:81:29)
at new Route (node_modules/react-router/Route.js:56:20)
at constructClassInstance (node_modules/react-dom/cjs/react-dom.development.js:6801:20)
at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:8336:9)
at beginWork (node_modules/react-dom/cjs/react-dom.development.js:8982:16)
at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:11814:16)
at workLoop (node_modules/react-dom/cjs/react-dom.development.js:11843:26)
at renderRoot (node_modules/react-dom/cjs/react-dom.development.js:11874:9)
at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12449:24)
at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
at node_modules/react-dom/cjs/react-dom.development.js:16488:14
at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous>.done (src/__tests__/integrations.test.js:20:37)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
at process._tickCallback (internal/process/next_tick.js:68:7)
FAIL src/components/tests/App.test.js
● shows a comment box
Invariant Violation: Could not find "store" in either the context or props of "Connect(App)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(App)".
at invariant (node_modules/invariant/invariant.js:40:15)
at new Connect (node_modules/react-redux/lib/components/connectAdvanced.js:134:33)
at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:123:26)
at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:287:35
at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:94:16)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:286:68)
at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:119:22)
at shallow (node_modules/enzyme/build/shallow.js:19:10)
at Object.<anonymous>.beforeEach (src/components/__tests__/App.test.js:10:33)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● shows a comment box
TypeError: Cannot read property 'find' of undefined
at Object.<anonymous>.it (src/components/__tests__/App.test.js:14:18)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● shows a comment list
Invariant Violation: Could not find "store" in either the context or props of "Connect(App)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(App)".
at invariant (node_modules/invariant/invariant.js:40:15)
at new Connect (node_modules/react-redux/lib/components/connectAdvanced.js:134:33)
at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:123:26)
at node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:287:35
at withSetStateAllowed (node_modules/enzyme-adapter-utils/build/Utils.js:94:16)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:286:68)
at new ShallowWrapper (node_modules/enzyme/build/ShallowWrapper.js:119:22)
at shallow (node_modules/enzyme/build/shallow.js:19:10)
at Object.<anonymous>.beforeEach (src/components/__tests__/App.test.js:10:33)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● shows a comment list
TypeError: Cannot read property 'find' of undefined
at Object.<anonymous>.it (src/components/__tests__/App.test.js:18:18)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
FAIL src/components/tests/CommentBox.test.js
● Console
console.error node_modules/react-dom/cjs/react-dom.development.js:9643
The above error occurred in the <ComposedComponent> component:
in ComposedComponent (created by Connect(ComposedComponent))
in Connect(ComposedComponent) (created by Connect(Connect(ComposedComponent)))
in Connect(Connect(ComposedComponent)) (at CommentBox.test.js:11)
in Provider (at Root.js:14)
in Unknown (created by WrapperComponent)
in WrapperComponent
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.error node_modules/react-dom/cjs/react-dom.development.js:9643
The above error occurred in the <ComposedComponent> component:
in ComposedComponent (created by Connect(ComposedComponent))
in Connect(ComposedComponent) (created by Connect(Connect(ComposedComponent)))
in Connect(Connect(ComposedComponent)) (at CommentBox.test.js:11)
in Provider (at Root.js:14)
in Unknown (created by WrapperComponent)
in WrapperComponent
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
console.error node_modules/react-dom/cjs/react-dom.development.js:9643
The above error occurred in the <ComposedComponent> component:
in ComposedComponent (created by Connect(ComposedComponent))
in Connect(ComposedComponent) (created by Connect(Connect(ComposedComponent)))
in Connect(Connect(ComposedComponent)) (at CommentBox.test.js:11)
in Provider (at Root.js:14)
in Unknown (created by WrapperComponent)
in WrapperComponent
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
● has a text area and two buttons
TypeError: Cannot read property 'push' of undefined
at ComposedComponent.shouldNavigateAway (src/components/requireAuth.js:18:28)
at ComposedComponent.componentDidMount (src/components/requireAuth.js:8:12)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:9784:26)
at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:11455:9)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:138:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:187:29)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:11594:9)
at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:12502:36)
at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12452:11)
at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
at node_modules/react-dom/cjs/react-dom.development.js:16488:14
at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous>.beforeEach (src/components/__tests__/CommentBox.test.js:9:31)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● has a text area and two buttons
TypeError: Cannot read property 'find' of undefined
at Object.<anonymous>.it (src/components/__tests__/CommentBox.test.js:21:18)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● has a text area and two buttons
TypeError: Cannot read property 'unmount' of undefined
at Object.<anonymous>.afterEach (src/components/__tests__/CommentBox.test.js:17:11)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › has a text area that users can type in
TypeError: Cannot read property 'push' of undefined
at ComposedComponent.shouldNavigateAway (src/components/requireAuth.js:18:28)
at ComposedComponent.componentDidMount (src/components/requireAuth.js:8:12)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:9784:26)
at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:11455:9)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:138:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:187:29)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:11594:9)
at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:12502:36)
at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12452:11)
at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
at node_modules/react-dom/cjs/react-dom.development.js:16488:14
at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous>.beforeEach (src/components/__tests__/CommentBox.test.js:9:31)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › has a text area that users can type in
TypeError: Cannot read property 'find' of undefined
at Object.beforeEach (src/components/__tests__/CommentBox.test.js:27:13)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › has a text area that users can type in
TypeError: Cannot read property 'find' of undefined
at Object.it (src/components/__tests__/CommentBox.test.js:34:20)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › has a text area that users can type in
TypeError: Cannot read property 'unmount' of undefined
at Object.<anonymous>.afterEach (src/components/__tests__/CommentBox.test.js:17:11)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › when form is submitted, text area gets emptied
TypeError: Cannot read property 'push' of undefined
at ComposedComponent.shouldNavigateAway (src/components/requireAuth.js:18:28)
at ComposedComponent.componentDidMount (src/components/requireAuth.js:8:12)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:9784:26)
at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:11455:9)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:100:14)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:138:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:187:29)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:11594:9)
at completeRoot (node_modules/react-dom/cjs/react-dom.development.js:12502:36)
at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:12452:11)
at performWork (node_modules/react-dom/cjs/react-dom.development.js:12370:9)
at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:12347:5)
at requestWork (node_modules/react-dom/cjs/react-dom.development.js:12247:7)
at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:12122:13)
at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:12082:12)
at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:12710:5)
at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:12738:12)
at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:12765:14)
at ReactRoot.Object.<anonymous>.ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:16069:15)
at node_modules/react-dom/cjs/react-dom.development.js:16488:14
at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:12557:12)
at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:16484:17)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:16543:12)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:218:50)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous>.beforeEach (src/components/__tests__/CommentBox.test.js:9:31)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › when form is submitted, text area gets emptied
TypeError: Cannot read property 'find' of undefined
at Object.beforeEach (src/components/__tests__/CommentBox.test.js:27:13)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › when form is submitted, text area gets emptied
TypeError: Cannot read property 'find' of undefined
at Object.it (src/components/__tests__/CommentBox.test.js:38:13)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
● the text area › when form is submitted, text area gets emptied
TypeError: Cannot read property 'unmount' of undefined
at Object.<anonymous>.afterEach (src/components/__tests__/CommentBox.test.js:17:11)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
When I npm install on the client I get the above warning.
i want to show error if user enter wrong credential but my mapStateProps function not getting connect(102 video)
here is my question
https://stackoverflow.com/questions/50258436/unable-to-assign-state-in-mapstatetoprops
Just cloned the repo. Try to run the server side (auth) . looks like ../config in authentication.js is missing.
Server Post Sign In Invalid Arguments it will occur in the bcrypt.comparePassword method.
Wouldn't it be a good idea to add webpack config and script to build on of the projects to production?
Your test code wasn't passing so I had to do some research to get it to work. One thing I found was that test_helper.js might need to be updated to use ReactTestUtils instead of TestUtils.
So the following changes to test_utils.js:
import ReactTestUtils from 'react-dom/test-utils';
in renderComponent:
const componentInstance = ReactTestUtils.renderIntoDocument(
in build helper for simulating events:
$.fn.simulate = function(eventName, value) {
,,,
ReactTestUtils.SimulateeventName;
};
I found your "auth/server" project, you defined the 'services/passport.js' file, but you didn't export it, and used it nowhere. I was wondering how to use it?
So I ran your Mocha/Chai tests and they failed. I kept getting this error:
TypeError: document.createElement is not a function
at Object.renderIntoDocument (node_modules\react-dom\lib\ReactTestUtils.js:85:24)
at renderComponent (C:/User/Owner/mocha-chai/test/test_helper.js:29:46)
at Context.<anonymous> (C:/User/Owner/mocha-chai/test/components/app_test.js:14:21)
So I looked at the React docs for renderIntoDocument and it states:
**renderIntoDocument(element)
Render a React element into a detached DOM node in the document. This function requires a DOM.
Note:
You will need to have window, window.document and window.document.createElement globally available before you import React. Otherwise React will think it can't access the DOM and methods like setState won't work.**
So if you look at the note you are not doing what it states in your tests. I tried to set window, window.document and window.document.createElement directly but I'm a noob at React so I used a solution from StackOverFlow:.
so app_test.js will look like this:
import { renderComponent, expect } from '../test_helper';
import App from '../../src/components/app';
import {beforeEach} from 'mocha';
import jsdomify from 'jsdomify';
let React;
// Use 'describe' to group together similar tests
describe('App', () => {
let component;
beforeEach(() => {
jsdomify.create();
React = require('react');
component = renderComponent(App);
});
it('shows a comment box', () => {
expect(component.find('.comment-box')).to.exist;
});
it('shows a comment list', () => {
expect(component.find('.comment-list')).to.exist;
});
});
For anyone stuck on Advanced Redux - Clientside Auth Section 7, Lecture 94 at 10 minutes, here's a fix that will let you move on.
Issue: There's no way to move forwards from this part of the Client Side Auth lecture as latest updates to reduxForm mean signinUser (and other variables) doesn't get passed to props. You'll probably also notice before then that email and password can't be console.logged from your handleFormSubmit function either.
Hitting the Sign Up button will throw Uncaught TypeError: this.props.signinUser is not a function(…)
Fix: A quick fix, though not ideal, is to open package.json and change the redux-form dependency to version 5.3.3. This will let you continue.
"redux-form": "5.3.3",
@StephenGrider fyi
Hi. I got next error - Cannot find module "../../actions/" in signin.js:3
don't know why, but my webpack don't want import * as actions from '../../actions';
i'm sorry, that was my mistake
So in your package.json in /AdvancedReduxCode/testing/package.json you have this line of code under 'scripts':
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.js'",
The quotes around 'test/**/*.js' cause the script to fail. Once I remove them it runs fine. I'm running in a terminal on Windows 10 machine.
I am running on OS Windows_NT 10.0.10586
Exit status 1
Error Msg was:
Error: cannot resolve path (or pattern) ''test/**/*.js''
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.