Sample Assessment for a Rails & React-Redux app.
Slides from React.js Meetup presentation available here.
npm install
bundle install
bundle exec rake db:setup
- NB: you will need to have a ListinggreSQL server running!
- All required backend code is provided
To test your code live in the browser, run:
rails server
webpack --watch
- Navigate to localhost:3000.
NB: you do not need to have a server or webpack running to run and pass specs.
You will be running your code using Jest. Navigate to the root folder of the
skeleton and run npm test
to run all specs at once.
To run a single spec file, see 'Debugging Tips' section below.
For this assessment, Jest specs live in a single __tests__
folder within the
frontend folder.
We recommend passing your specs in this order:
Entry point test:
frontend/__tests__/reactA06-test.js
Redux tests:
frontend/__tests__/listing_api_util-test.js
frontend/__tests__/listing_actions-test.js
frontend/__tests__/reducers-test.js
frontend/__tests__/store-test.js
Component tests:
frontend/__tests__/listing_index-test.js
- Write
ListingIndexContainer
beforeListingIndex
(spec file tests both)
frontend/__tests__/listing_index_item-test.js
frontend/__tests__/listing_form-test.js
- Write
ListingFormContainer
beforeListingForm
(spec file tests both)
frontend/__tests__/listing_show-test.js
- Write
ListingShowContainer
beforeListingShow
(spec file tests both)
Jest is Facebook's defacto testing framework for React components and Flux apps.
Here are some tips for making debugging a little less intimidating.
-
Look at the test file to see how we expect the method to behave. Jest reads similarly to RSpec & Jasmine.
-
For more control over how specs are run, Install jest globally:
npm install -g jest-cli
. You will now be able to run the following commands:
jest frontend/__tests__/somepath/sometest.js
- run a single test file (HIGHLY RECOMMENDED)
jest --watch
- similar to
webpack --watch
, will update every time there is a change
- similar to
jest -o
- will find and run only those tests related to changed Javascript files
jest --bail
- similar to
--fail-fast
, will abort test run after first error - execution does not stop after first failed test, but at end of file.
Therefore it is only useful when running the full test suite.
- similar to