测试描述的开玩笑不是一个功能

时间:2018-01-10 18:30:17

标签: redux jestjs

我使用react和redux创建了一个应用程序,我有一些组件加上他们的容器,还有一个动作和一个减速器。

我正在使用酶,柴和开玩笑为我的一个容器编写测试,

当我尝试运行测试时,会出现以下错误:

Test suite failed to run

    TypeError: jest_1.describe is not a function

这是我的测试文件:

import * as React from "react";
import { shallow, mount, render } from 'enzyme';
import * as Sinon from "sinon";
import MinPriceContainer from "../../src/containers/SearchForm/containers/MinPriceContainer";
import MaxPriceContainer from "../../src/containers/SearchForm/containers/MaxPriceContainer";
import { expect } from "chai";
import { it, before, describe } from 'jest';

describe('<MinValueInput />', () => {

    let minValueInput;
    beforeEach(() => {
        minValueInput = shallow(<MinPriceContainer />);
    })

//    it('renders component correctly', () => {
//        expect(tabs.find('.MinPriceComponent').exists()).toBe(true);
//    });

    it('cannot have a non numeric value', () => {
        minValueInput = shallow(<MinPriceContainer minimumPriceSelected="i am a string not a number" />);
        expect(minValueInput.find('.error').text()).equal("You cannot use a non numeric value");
    });

    it('cannot have a value less thn zero', () => {
        minValueInput = shallow(<MinPriceContainer minimumPriceSelected={-20} />);
        expect(minValueInput.find('.error').text()).equal("value cannot be less than zero");
    });

    it('it can not have a value greater than maxValue', () => {
        minValueInput = shallow(<MinPriceContainer minimumPriceSelected={99} maximumPriceSelected={80}/>);
        expect(minValueInput.find('.error').text()).equal("value cannot be greater than price");
    });
});

我该如何解决这个问题,这与我的importS有关吗? 测试写得正确吗?

我正在测试的组件有一个名为minPrice的数字值,它不能是负数,也不应该是另一个名为maxPrice的组件,它也应该只接受数字!

1 个答案:

答案 0 :(得分:0)

我认为您使用的是ts-jest?

替换

import { it, before, describe } from 'jest';

import 'jest';