Closed muratakburak closed 3 years ago
Hmm I have no idea... that's not a very helpful stack unfortunately. I'm not sure where I'd start to help here. If you make a small repo recreating the bug I could spin it up, but I'm on a Mac and it looks like you are on Windows, so not sure if it will happen on my Mac. But I'd try.
In the meantime can you try a sanity test by adding this test to your suite (comment all other jest.when usages):
it('works with basic args and return', () => {
const fn = jest.fn()
when(fn).calledWith(1).mockReturnValue('success')
expect(fn(1)).toEqual('success')
})
I couldn't reproduce with running only one test you provided which is the only place where jest-when is used. I can try to create a small repo that you can try to repro but maybe after a week.
Hi @timkindberg can you check this repo https://github.com/muratakburak/jest-when-crash It also happens with this one.
🤔 Hmm I ran it and it worked. I really am not sure what the issue might be here. The stack trace is nothing I've seen before. It seems related to the Node V8 Engine, which makes me think maybe it's related to Windows Node?? I really don't know.
Ok, thanks. Looks like I'll have to look for an alternative to get desired behaviour. Any suggestions? Or maybe I can post it somewhere else?
I'd recommend stack overflow.
I have used jest-when library to mock reading of a specific file like below
when(mockedReadFileSync).calledWith(path.resolve(__dirname, "./../../assets/settings.json"), { encoding: "utf-8" }).mockReturnValue(JSON.stringify(settingsFileContent));
It has been almost a week since I used the library in my project but is started throwing errors today. I've searched about it but only found some records about gulp.
Here is my task in vscode. When I run it, it gives me error below. Never fails when I comment out the only line of code that I use jest-when. Seemed like a version issue after I read the discussions about gulp but I am not sure. Any help is appreciated.