Jest 24.1和babel 7.3.3在大多数测试中仍然存在问题

时间:2019-02-20 08:34:18

标签: reactjs jestjs babel

好吧,我已经为此烦恼了几天。因此,我最终将向StackOverflow的优秀人员寻求急需的帮助:)

Here is the error I'm getting => Identifier 'global' has already been declared

And it seems to not recognize the require keyword

因此,目前,测试套件的50%通过了。

它似乎仅在调用redux reducers的测试中抛出。由于几乎所有失败的测试的错误都是相同的。

这是我当前的df1 = pd.DataFrame({'col1':[1,2,3,None,5], 'col2':[25,5,None,None,1], 'col3':[40,3,None,None,None]}, index=[datetime.date(2015,7,7),datetime.date(2015,7,12),datetime.date(2015,8,1),datetime.date(2015,8,10),datetime.date(2015,9,20)]) df2 = pd.DataFrame({'col1':[14,82,None,None,1], 'col2':[5,5,None,4,1], 'col3':[4,3,5,None,6]}, index=[datetime.date(2015,7,10),datetime.date(2015,7,15),datetime.date(2015,8,4),datetime.date(2015,8,12),datetime.date(2015,9,25)]) df3 = pd.DataFrame({'col1':[10,9,None,None,15], 'col2':[None,5,None,3,1], 'col3':[None,3,3,1,74]}, index=[datetime.date(2015,7,5),datetime.date(2015,8,1),datetime.date(2015,8,9),datetime.date(2015,8,10),datetime.date(2015,9,20)]) fig=plt.figure(figsize=(15, 15)) ax1 = plt.subplot(313) ax2 = plt.subplot(312, sharex = ax1) ax3 = plt.subplot(311, sharex = ax1) for column in df1.columns: ax1 = plt.scatter(df1.index, df1[column], s=2) for column in df2.columns: ax2 = plt.scatter(df2.index, df2[column], s=2) for column in df3.columns: ax3 = plt.scatter(df3.index, df3[column], s=2) plt.show()

babel.config.js

依赖项位于

module.exports = function(api) {
    const isTest = api.env('test')

    const presets = [
        isTest && [
            '@babel/preset-env',
            {
                targets: {
                    node: 'current',
                },
            },
        ],
        [
            'next/babel',
            {
                'preset-env': {},
                'transform-runtime': {},
                'styled-jsx': {},
                'class-properties': {},
            },
        ],
    ].filter(Boolean)

    const plugins = ['babel-plugin-styled-components']

    return {
        presets,
        plugins,
        sourceType: 'unambiguous',
    }
}

1 个答案:

答案 0 :(得分:-1)

好的,我现在修复了它,这不是玩笑或通天塔的问题。 我猜到了,保留名称作为变量,自从最新的babel以来,它会引发混乱的错误。

This was the fix! :)