Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page contains a list of common questions that new contributors might have when getting started, and hopefully provides useful answers.
This list is a work in progress, please feel free to add anything that new contributors might find useful.

Table of Contents

Do I need to configure a local database for testing?

No, while the test command points to a local database, vly-test, this is actually an in-memory database that is created during execution of the test script for the purpose
of running the tests. You don't need to do anything but run the test script by typing "npm run test".


My module page works except when I force a reload.

App uses server side rendering, so when a forced reload is requested the page is fully rendered server side. Normally only the first page is rendered and others are loaded dynamically.

The difference is whether the page has requested data to be loaded into the store from the client side or the server side.

The first place to check for problems is in the routes.js file.

Code Block
if (process.env.NODE_ENV !== 'production') {
  // Require async routes only in development for react-hot-reloader to work.
  require('./modules/Post/pages/PostListPage/PostListPage');

Make sure that you have required all your module pages that are liable to be reloaded from the browser. i.e pages rather than components.

You may see this type of warning

Code Block
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
    in PersonUpdatePage
    in Connect(PersonUpdatePage)
    in withRouter(Connect(PersonUpdatePage))
   


I'm on a Mac, and running 'mongod' seems to be erroring out?

The solution may be found here; the problem may be that you aren't pointing to an existing /data/db folder.

To do this, run the command as follows: 'mongod --dbpath <absolute path to /data/db folder within vly1 repo>' (E.g for me it was 'mongod --dbpath ~/Documents/workspace/vly1/data/db/').

What is this Redux debug sidebar ?

This is included in client/store.js. and comes from client/modules/App/components/DevTools.js

There are mutiple tools in the dock

LogMonitor
The default monitor for Redux DevTools with a tree view.
It shows a log of states and actions, and lets you change their history.
This is wrapped in DockMonitor to create the sidebar.
toggleVisibilityKey="ctrl-h"
changePositionKey="ctrl-w"
defaultSize="0.2"

Getting "E11000 duplicate key" errors with MongoDB

This error can occur when you try and insert a record when an index field is "left over" that shouldn't be there. These can remain even if you update the Schema. You'll need to manually clear the offending index in your database (or just drop the database (smile) ). See this page for further details: https://stackoverflow.com/questions/23695676/mongoosejs-cant-disable-unique-to-field



AVA **/file no longer works

Ava - the test runner we use in npm test used to take glob wild cards like **/OpDetails.spec.js  which would find the file in any folder.   In the upgrade to v4 this was removed.  Instead you have to specify a complete path to the target file.

On Mac and Linux you can use the back tick to generate the appropriate list of files into the command line

Code Block
npm test `**/OpDetail*.spec`

> @voluntarily/vly2@1.0.0 test /Users/watkinsav/workspace/voluntarily/vly2
> cross-env NODE_ENV=test PORT=8080 node_modules/.bin/nyc node --no-deprecation node_modules/ava/cli.js "components/Op/__tests__/OpDetail.spec.js" "components/Op/__tests__/OpDetailForm.spec.js" "components/Op/__tests__/OpDetailTagsEditable.spec.js"



Test cases using mongodb memory database timed-out without completing in Ubuntu 18.04 LTS


After a package update in 18.04. some ava tests were timed out and displyed a messafge like below.

Code Block
✖ Timed out while running tests
20 tests were pending in /home/hari/github_repo/voluntarily/backup/vly2/server/api/activity/tests/activity.spec.js

The issue was that default mongod library has some issues. So I have to remove it and installed the mongodb community version.
To remove mogodb follow these steps
  1. sudo apt remove mongodb
  2. sudo apt purge mongodb
  3. sudo apt-get autoremove
Finally, remove the data folder as well.( I tried to keep the database , but the mongo service did not work correctly if we keep this folder)
Follow the instructions here to install MongoDB Community edition in Ubuntu.

Simulate onChange is not working when the component is rendered using Mount 

The change event is not working with the antd Select component for some reason when the component is rendered using mount.

The quick fix was to render the component using shallow. The code below is an example to simulate a change event using shallow rendering.

Code Block
languagejs
const handleSort = sinon.fake((sortOrder) => t.is(sortOrder, 'name'))
  const wrapper = shallowWithIntl(
    <OpOrderBy onChange={handleSort} />
  )
  wrapper.find('Select').first().simulate('change', 'name')

Getting "' 'rm' is not recognized as an internal or external command" error when running npm test in Windows

The issue occurs when Windows doesn't recognize Linux commands in the command prompt.

The fix is to add the git bin folder location in the system environment variables→ environment variables→ path variable for the windows user. For details check the last answer https://stackoverflow.com/questions/49032646/ls-is-not-recognized-as-an-internal-or-external-command-operable-program-or-b