TypeError: seamless immutable _1.default is not a function - React native jest unit testing (Typescript)
TypeError: seamless immutable _1.default is not a function - React native jest unit testing (Typescript)
我正在尝试对基于 typescript 的 react native 进行开玩笑的单元测试 project.Now 我在进行 npm 测试时遇到了一个问题。下面提到的错误
● 测试套件未能 运行
TypeError: seamless_immutable_1.default is not a function
34 |
35 |
> 36 | export const INITIAL_STATE: ImmutableAppReducerState = Immutable({
| ^
37 | activeTab: 0,
38 | showTab: false,
39 | tabName: "",
我的实际代码如下
从“无缝不可变”导入不可变;
export interface AppReducerState {
activeTab?: number | undefined;
showTab?: boolean | undefined;
tabName?: string | undefined;
isDrawerOpen: boolean;
retryAction: AnyAction[];
}
/* ------------- Initial State ------------- */
type ImmutableAppReducerState = Immutable.Immutable<AppReducerState>
export const INITIAL_STATE: ImmutableAppReducerState = Immutable({
activeTab: 0,
showTab: false,
tabName: "",
isDrawerOpen: false,
retryAction: [],
});
回答我的问题
只需修改我的代码
1. import * as Immutable from "seamless-immutable";
2. export const INITIAL_STATE: ImmutableAppReducerState = Immutable
to
export const INITIAL_STATE: ImmutableAppReducerState = Immutable.from
我正在尝试对基于 typescript 的 react native 进行开玩笑的单元测试 project.Now 我在进行 npm 测试时遇到了一个问题。下面提到的错误
● 测试套件未能 运行
TypeError: seamless_immutable_1.default is not a function
34 |
35 |
> 36 | export const INITIAL_STATE: ImmutableAppReducerState = Immutable({
| ^
37 | activeTab: 0,
38 | showTab: false,
39 | tabName: "",
我的实际代码如下
从“无缝不可变”导入不可变;
export interface AppReducerState {
activeTab?: number | undefined;
showTab?: boolean | undefined;
tabName?: string | undefined;
isDrawerOpen: boolean;
retryAction: AnyAction[];
}
/* ------------- Initial State ------------- */
type ImmutableAppReducerState = Immutable.Immutable<AppReducerState>
export const INITIAL_STATE: ImmutableAppReducerState = Immutable({
activeTab: 0,
showTab: false,
tabName: "",
isDrawerOpen: false,
retryAction: [],
});
回答我的问题
只需修改我的代码
1. import * as Immutable from "seamless-immutable";
2. export const INITIAL_STATE: ImmutableAppReducerState = Immutable
to
export const INITIAL_STATE: ImmutableAppReducerState = Immutable.from