redux-zero / redux-zero

A lightweight state container based on Redux

Home Page:https://matheusml1.gitbooks.io/redux-zero-docs/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't test redux-zero with JEST and TypeScript?

gerardcsaperas opened this issue · comments

Hi!

I'm getting the following error message when I try to write unit tests for files that access the redux-zero store (just by importing the files, not even writing tests).

Test suite failed to run

    TypeError: (0 , redux_zero_1.default) is not a function

      1 | import createStore from 'redux-zero';
      2 | /** create redux-zero store */
    > 3 | const store = createStore({
        |               ^
      4 |     appDimensions: {
      5 |         width: 0,
      6 |         height: 0

      at Object.<anonymous> (src/data/store.ts:3:15)
      at Object.<anonymous> (src/utils/remoteControl.ts:3:1)

This is how you import it with TypeScript:

import * as createStore from "redux-zero";

It's documented here: https://github.com/redux-zero/redux-zero#how

Hi @matheusml ,

When I do this:

import * as createStore from 'redux-zero';

/** create redux-zero store */
const store = createStore({

TypeScript's linter gives me the following error message for createStore:

This expression is not callable.
      Type 'typeof import("/Users/<...>/node_modules/redux-zero/index")' has no call signatures.