Lessons learned testing React & Redux apps with Jest and Enzyme

Lessons learned #testing #reactjs  & #Redux #apps with #Jest and #Enzyme  #javascript

  • It makes things much easier, and you can pattern match (hit p then type part of your file/folder name) to make sure you’re not running a ton of things every save.Make sure you don’t close off your test() statements early.Parentheses man… 😢Is perfectly valid Javascript, but your test (while it…
  • I only noticed that I had this copy and pasted for one section of my unit tests when I made an error and realized the test didn’t fail.Which leads me to…Make sure your tests failIf you’re awesome and use TDD, then props to you you’re already doing this 🎉For the rest…
  • Time to move on.”However this leads to errors like the aforementioned one, and it’s surprisingly easy to grab and test the wrong element or mocked function — especially if you’re copy pasting from a similar test.It’s not hard to just comment out an essential section of a test and make sure it…
  • It’s also easy to copy to another component with a similar need for testing.In fact all of the little conventions I’m following here (beforeEach mounting a wrapper, what I name things, spreading a props object) are great to have defined somewhere so people can easily understand and copy test functionality…
  • It also makes testing quite simple and separates rendering vs data concernsI try to extract any complex data manipulation to pure functions and test thoseI use end to end (Selenium) and integration tests to check on sections of my app to make sure it all fits together.It’s not perfect, I’m…

If you don’t work at a primarily tech company, it can be a bit difficult to convince managers of the importance of things like unit testing. After being a enthusiastic supporter for quite a while, I…
Continue reading “Lessons learned testing React & Redux apps with Jest and Enzyme”

Monday & #ReactNative 💙 #iOS #Android #mobile #apps #DevOps #software

Monday & #ReactNative 💙 


#iOS #Android #mobile #apps #DevOps #software

  • That’s why, today I’d like to share a number of things that boost my productivity while creating mobile app in React Native.
  • Storybook allows you to create stories in which you prepare pre filled UI elements with data that could possibly show up there during normal app lifetime.
  • Later within a few seconds you can easily go through all stories that you’ve described and see how they look on your device / emulator without the need of going through all of these states in normal app flow which takes much longer time.
  • This is a tiny example of a single story, however if you develop a normal app, you will surely have much more of them which may cover all of possible UI states for your components.
  • If your app grows, it’s easy to guess that tests will not run in a matter of milliseconds, but it’s still normal to have a result of them within 1-3 seconds from the time that you saved your file.

A developer needs tools that support her/his workflow to be fully productive. Well, I guess that this statement fits to any profession that you can think of. It is really important for me to feel that the environment that I’m working in really supports my flow and works well with my approach to software development.
Continue reading “Monday & #ReactNative 💙

#iOS #Android #mobile #apps #DevOps #software”

Getting up and running with #reactjs @FableCompiler and Suave on #netcore #fsharp

  • The Fable compiler is used to compile the F# client code to JavaScript so that it can run in the browser.
  • If you look at then you will see code that is shared between client and server.
  • NET core and for the client the Fable compiler is translating it into JavaScript.
  • With Expecto you write tests as values in normal code.
  • If you are in development mode then you can use Expecto’s focused test feature to run a selected test against the running server.

fable-suave-scaffold – Working sample of a Suave + Fable + Elmish project with hot reloading
Continue reading “Getting up and running with #reactjs @FableCompiler and Suave on #netcore #fsharp”

Organizing Tests in Jest – Jeff Lombard – Medium

Organizing Tests in Jest  #jest #javascript #react #softwaretesting #reactjs

  • This includes organization.I’ve seen two popular ways suggested for organizing tests in Jest:Putting all of your test code into a neatly organized /tests directory.Putting your test code next to the files they are testing.Both of these suggestions are valid, but to have the elegance of a master craftsman, we should consider the level of the test that is being written.Testing LevelsThere are many testing levels, but for simplicity we’re just going to talk about two here.
  • “Unit testing refers to tests that verify the functionality of a specific section of code, usually at the function level.
  • |- /main| |- index.js| |- index.test.jsIntegration tests run against many lines of code in many files.
  • So include the type of test right in the name of the and api.int.test.jsConclusionAn ideal set up would look something like this:|- /main| |- index.js| |- index.unit.test.js|- /supporting| |- fetch.js|- /tests| |- /int| | |- api.int.test.jsThat way you can easily find your tests.
  • For unit testing run jest unit and for integration testing run jest int.As with anything, there is no single way of doing this.

If you haven’t already tried out Jest, you should. Even if you’re not using React. It’s dead simple and loaded with some cool features like snapshot testing. Jest does a great job of keeping reports…
Continue reading “Organizing Tests in Jest – Jeff Lombard – Medium”

How to structure real world Redux/React application – Medium

  • I decided to move the tests into the src/app folder so that they are close to the source.
  • It’s quite easy to see this coming because the file nature will always remain the same but features and data domains grow in real world applications .
  • -app/ – data/ – artifacts/ ArtifactReducer.js ArtifactActions.js ArtifactSelectors.js – calls/ CallsReducer.js CallsActions.js CallsSelectors.js – filters/ …
  • ./data/calls/CallReducer.js’; import * as CallActions from ‘.
  • A better way is to encapsulate the data domain by creating an index.js that exports the internal files of this module.

Recently I was rewriting in Redux/React the web application of Flow, a tool to help developers better understand the structure and the…
Continue reading “How to structure real world Redux/React application – Medium”

How to Test React and MobX with Jest

New tutorial: How to Test @ReactJS and MobX with Jest by @LearnCodeAcad
 #JavaScript #TDD

  • createTodo ( “todo2” ) expect ( store .
  • toBe ( “todo1” ) expect ( store .
  • //don’t use an arrow function, preserve the value of “this” it ( “renders filtered todos” , function () { const wrapper = shallow ( < TodoList store = { this .
  • Since MobX stores act just like object literals, we can test our React component by injecting it with any object literal to simulate a store state.
  • If you want to do this with React and MobX, you should simply replace the mock store with a real MobX store.

Read the full article, click here.


@semaphoreci: “New tutorial: How to Test @ReactJS and MobX with Jest by @LearnCodeAcad
#JavaScript #TDD”


If you’re developing React applications, then you know that the React community has been
bursting with new ideas and tools over the last year. When investigating any
new technology to incorporate into a stack, we should consider if it either
makes the workflow much easier, or solves a key problem. MobX and Enzyme are 2 new
libraries in the React world that fit the bill. This sample todo application
is incredibly easy to build with React and MobX, and in this article we’ll cover
unit and UI/functional testing for React and MobX with Enzyme.


How to Test React and MobX with Jest

reactjs-datepicker

  • We’re always trying to stay compatible with the latest version of React.
  • To extend the examples with a new example, you can simply duplicate one of the existing examples and change the unique properties of your example.
  • The example below shows how to include the css from this package if your build system supports requiring css files (webpack is one that does).
  • The master branch contains the latest version of the Datepicker component.
  • By default, the date picker will use the locale globally set in moment, which is English.

Read the full article, click here.


@npmdaily: “reactjs-datepicker – A simple and reusable datepicker component for React #npm #javascript #nodejs”


A simple and reusable datepicker component for React


reactjs-datepicker

Introducing Provider, implements #53 by mweststrate · Pull Request #65 · mobxjs/mobx-react · GitHub

  • mweststrate commented on the diff Jun 21, 2016
  • Mweststrate referenced the pull request Jun 21, 2016
  • + `Provider` is a component that can stores (or other stuff) on React’s context.
  • Sign up for free to join this conversation on GitHub .
  • mweststrate wants to merge 7 commits into master from provider

Read the full article, click here.


@mweststrate: “Most requested feature: mobx-react Provider + connect mechanism is coming!
#MobX #reactjs”


mobx-react – React bindings for MobX


Introducing Provider, implements #53 by mweststrate · Pull Request #65 · mobxjs/mobx-react · GitHub

“A fairer Vue of React”

  • Overall, the original claims about Vue’s performance still hold some value in this use case but there was clearly a lot of opportunity for optimisation – especially with React.
  • Our first test suggested that Vue massively outperformed React, which was very sensational and unexpected, but was caused by running the tests in development mode.
  • It should be stressed that Vue was also running in development mode, so both tests were equally afflicted.
  • Considering how many improvements have been made as a result of the first post there is nothing to say there can be no further improvements.
  • Note that the results of this first post have been invalidated by some unfortunate mistakes, but this should set the context for this post.

Read the full article, click here.


@fr_devs: “New! Follow-up investigation from @MaxWillmott “A fairer Vue of React” @vuejs @reactjs #reactjs #vuejs #javascript”


For part one, please visit: https://engineering.footballradar.com/from-a-react-point-of-vue-comparing-reactjs-to-vuejs-for-dynamic-tabular-data/. Note that the results of this first post have been invalidated by some unfortunate mistakes, but this should set the context for this post.


“A fairer Vue of React”

Building Applications with React and Redux in ES6

It's live! React & Redux in ES6 just published on Pluralsight! 

#reactjs #javascript

  • You will create a rapid feedback development environment that runs linting and tests, transpiles ES6 to ES5, starts up Express as a webserver, opens the application, and hot reloads changes every time you hit save and deploys with a single command.
  • 0m 43s Create Initial Components 3m 16s Create App Layout 1m 23s Configure Routing 1m 47s Update Entry Point 3m 9s Create Styles 0m 41s Create Header 4m 30s Create Course Page 2m 46s Summary 0m 21s
  • 2m 35s Async Library Options 3m 18s Thunk Overview 1m 9s Mock API Setup 3m 34s Remove Inline Form 1m 54s Add Thunk to Store 1m 4s Create Load Courses Thunk 4m 7s Action Naming Conventions 0m 56s Load Courses in Reducer 0m 47s Dispatch Action on Page Load 2m 15s Create Course List Component 3m 26s Summary 0m 49s
  • 1m 37s Other Ways to Create Components 0m 35s Container vs. Presentation Components 3m 22s Summary 0m 57s
  • 0m 40s Testing Connected React Components 12m 51s Testing mapStateToProps 4m 27s Testing Action Creators 1m 57s Testing Reducers 5m 15s Testing Thunks 6m 13s Testing the Store 5m 32s Summary 0m 35s

Read the full article, click here.


@housecor: “It’s live! React & Redux in ES6 just published on Pluralsight!

#reactjs #javascript”


Learn how to use Redux, React Router, and ES6 to build a real world app with React.


Building Applications with React and Redux in ES6