Give a simple example of Jest test case

Let's write a test for a function that adds two numbers in sum.js file:

const sum = (a, b) => a + b;
export default sum;

Create a file named sum.test.js which contains actual test:

import sum from './sum';
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);

And then add the following section to your package.json:

"scripts": {
"test": "jest"

Finally, run yarn test or npm test and Jest will print a result:

$ yarn test
PASS ./sum.test.js
āœ“ adds 1 + 2 to equal 3 (2ms)

What is flux?

Flux is an application design paradigm used as a replacement for the more traditional MVC pattern. It is not a framework or a library but a new kind of architecture that complements React and the concept of Unidirectional Data Flow. Facebook uses this pattern internally when working with React.

The workflow between dispatcher, stores and views components with distinct inputs and outputs as follows:


Author of content
Edit this page

Made by Michael Sakhniuk