Line numbers are shown incorrectly when ussing mock-fs package.
See original GitHub issue- Issue
 
If you use mock-fs package the line numbers are shown icorrectly.
import Dog from "./Dog";
import * as mock from "mock-fs";
describe("Dog", () => {
	
	beforeAll(() => {
		mock({
			"path/to/file.txt": "my text content",
		});
	});
	afterAll(() => {
		mock.restore(); 
	})
	
	test("should woof", () => {
		const dog = new Dog();
		expect(dog.woof()).toBe("Woof!____ SHOULD FAIL AND DISPLAY LINE NUMBER 19");
               // but it shows error at line number 16
	});
});
- Expected behavior
 
When running the tests, the line number should be shown correctly. But instead the JS line number is shown (not the TS input file line number)
- Link to a minimal repo that reproduces this issue
 
https://github.com/jhm-ciberman/ts-jest-bug
- Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo
 
I cannot configure it because the test NEEDs to fail to show the line number.
Issue Analytics
- State:
 - Created 6 years ago
 - Reactions:2
 - Comments:9 (4 by maintainers)
 
Top Results From Across the Web
Unable to Mock Node fs Modules with Sinon
js . I think the problem arises due to how the mocked method is nested within the imported module fs as fs.promises.readdir ....
Read more >How to Mock the File System for Unit Testing in .NET
In this article, we are going to learn how to mock the file system and unit test a component that interacts with the...
Read more >mock-fs
This lets you run tests against a set of mock files and directories instead of lugging around a bunch of test fixtures.
Read more >How to mock files with TestDouble, TypeScript and Jest
In our case, we will be giving advice based on a fetched number of friends for a given person. import { fetchNumberOfFriendsFor }...
Read more >Best Practices for Spies, Stubs and Mocks in Sinon.js
In this test, we're using once and withArgs to define a mock which checks both the number of calls and the arguments given....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@jhm-ciberman
allowSyntheticDefaultImportsneeded to be set totruewhen using default imports. I’ve sent a PR with the patch to the linked repo. Let me know if that works for you@thiagoh is it the same issue your facing?
In either case, it would be better to open a new issue (link to this if it helps) so that your specific case can be discussed/fixed there