jestjs/jest

Import should be case sensitive

Open

#10,398 创建于 2020年8月12日

在 GitHub 查看
 (19 评论) (0 反应) (0 负责人)TypeScript (45,361 star) (6,653 fork)batch import
:bug: BugHelp WantedPinned

描述

🐛 Bug Report :

let's say we have a module named: Autosuggest. and we want to mock it.

import AutoSuggest from './AutoSuggest' // the filename is Autosuggest.js (lower s)
jest.mock('./AutoSuggest', () => ({get : jest.fn(() => 1000)}));

if we import it with camel cases, like: AutoSuggest, it doesn't throw any error. it just let us to do it, and it allow us to mock it. but the mocking actually doesn't work this way.

Why it's important to fix : After one day of debugging about why mocking doesn't work, i fixed it with fixing the cases. so the problem is : it increases debug time.

Expected bahaviur :

jest.mock('./AutoSuggest') should throw an error when there is a module called ./Autosuggest, but there isn't any module called ./AutoSuggest.

贡献者指南

Import should be case sensitive · jestjs/jest#10398 | Good First Issue