GithubHelp home page GithubHelp logo

advancedreduxcode's Introduction

AdvancedReduxCode

Code repository for an awesome course on React and Redux. See here

advancedreduxcode's People

Contributors

stephengrider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

advancedreduxcode's Issues

Test Case Issue

"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
)

Server Side Rendering

How to Convert these program into Server Side Rendering for Increase Page Load And Server Down Problem

undefined email and password

in the singin.js file when submitting the form console.log(email, password ) the result is undefined,undefined

test_helper.js needs updating

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;
};

REDUX THUNK breaks the test hepler

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));
}`

KEY into userList

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>
    );

tests failed for /testing code

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:

  • Clone this repo
  • Naviagte to the /testing folder
  • run npm install
  • run 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)

config is missing

Just cloned the repo. Try to run the server side (auth) . looks like ../config in authentication.js is missing.

Building for production

Wouldn't it be a good idea to add webpack config and script to build on of the projects to production?

Test script in

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;
};

auth server problem

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?

Problem with TestUtils.renderIntoDoucment

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:.

  1. install jsdomify.
  2. import jsdomify from 'jsdomify' into your test file.
  3. Set jsdomify.creat() before calling React in beforeEeach method.
  4. Do this for all test files. You have to do this for each "beforeEach". Then all tests passed.

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;
});

});

Newest version of redux-form makes tutorial impossible to continue. Advanced Redux - Clientside Auth Section 7, Lecture 94 at 10 minutes

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",

http://stackoverflow.com/questions/41138158/uncaught-typeerror-this-props-signinuser-is-not-a-function

@StephenGrider fyi

Get problem when running your code

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

Error with 'test' script in package.json of testing example

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.