小编Jer*_*emy的帖子

重复的文件名 - index.js - jest-haste-map

我在 Jest 中遇到此错误 - 文件路径不同,这让我想知道为什么会抱怨?我想我被告知 index.js 是一个重复的名称,即使模拟位于不同的路径上 - 当然不是?我在测试文件中使用了这两个文件的模拟 - 我无法将索引文件与玩笑一起使用吗?

jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/dist/Actions/SendDistributions/__mocks__/index.js
    * <rootDir>/dist/Actions/SendQualifications/__mocks__/index.js

jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/dist/Actions/SendQualifications/__mocks__/index.js
    * <rootDir>/dist/Actions/SendLeads/__mocks__/index.js

Run Code Online (Sandbox Code Playgroud)

jestjs

8
推荐指数
1
解决办法
1177
查看次数

嘲笑php测试中的碳对象

感谢您的时间。我已经从代码/测试中去除了绒毛。

我得到的最远的是 setAttribute 需要两个字符串作为参数,但是我传入了一个 Carbon 对象,作为测试套件的 Mockery 不喜欢它?是这样吗,有没有更好的方法来使用 Mockery/PHPUnit 测试日期?其他测试和代码有效,似乎只有这个测试有问题。

错误

1) Tests\Unit\Services\StageServiceTest::update_stage
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_13_App_Entities_Subcategory::setAttribute('stage_updated_at', object(Carbon\Carbon)). Either the method was unexpected or its arguments matched no expected argument list for this method

Objects: ( array (
  'Carbon\\Carbon' => 
  array (
    'class' => 'Carbon\\Carbon',
    'properties' => 
    array (
    ),
  ),
))
Run Code Online (Sandbox Code Playgroud)

测试的一点

        $subcategory = \Mockery::mock(Subcategory::class);
        $stage = \Mockery::mock(Stage::class);
        $subcategory
            ->shouldReceive('setAttribute')
            ->with('stage_updated_at', Carbon::now())
            ->once();
       $this->service->updateSubcategoryStage(self::SUBCATEGORY_ID, $stageId);
Run Code Online (Sandbox Code Playgroud)

代码的一点

        $subcategory->stage_updated_at = Carbon::now();
        $subcategory->save();
Run Code Online (Sandbox Code Playgroud)

php testing mockery

5
推荐指数
1
解决办法
204
查看次数

更漂亮 / ESLint / React

从菜鸟导入 TS / React 的规则冲突,但使用 Eslint / Prettier 并收到错误'React' is declared but its value is never read.,但如果我删除它,'React' must be in scope when using JSX则会弹出错误。我不明白为什么!

ReactDOM.render(<Hello greeting="Site under construction..." />, document.getElementById('root'));
Run Code Online (Sandbox Code Playgroud)
import React from 'react';

export interface IProps {
    greeting: string;
}

function Hello({ greeting }: IProps) {
    return <div>{greeting}</div>;
}

export default Hello;

Run Code Online (Sandbox Code Playgroud)

/Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx /Users/Jeremyrrsmith/Coding/GitHub/portfolio-site/src/components/Hello.tsx 中的 TypeScript 错误(未定义,未定义):
' React' 已声明,但其值从未被读取。TS6133

但是如果我从上面的 Hello.tsx 中删除导入

src/components/Hello.tsx
第 6:12 行:使用 JSX react/react-in-jsx-scope 时,“React”必须在范围内

搜索关键字以了解有关每个错误的更多信息。

typescript reactjs eslint prettier

5
推荐指数
1
解决办法
2216
查看次数

标签 统计

eslint ×1

jestjs ×1

mockery ×1

php ×1

prettier ×1

reactjs ×1

testing ×1

typescript ×1