-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnhandledPromiseRejectionWarning appears even though rejection is caught #5604
Comments
You are using diff --git i/__tests__/methods/addNewPath.ts w/__tests__/methods/addNewPath.ts
index ee14c14..6e82170 100644
--- i/__tests__/methods/addNewPath.ts
+++ w/__tests__/methods/addNewPath.ts
@@ -19,7 +19,7 @@ describe('addNewPath', () => {
test('missing parameter', async () => {
let libInstance = new MediaScan();
const eventSpy = jest.spyOn(libInstance, 'addNewPath');
- await expect(libInstance.addNewPath()).rejects;
+ await expect(libInstance.addNewPath()).rejects.toThrowError();
expect(eventSpy).toHaveBeenCalled();
expect(eventSpy).toHaveBeenCalledTimes(1);
expect(libInstance.hasPathsProvidedByUser()).toBe(false);
@@ -29,7 +29,7 @@ describe('addNewPath', () => {
test('Not an existent path', async () => {
let libInstance = new MediaScan();
const eventSpy = jest.spyOn(libInstance, 'addNewPath');
- await expect(libInstance.addNewPath(path.join(__dirname, 'wrongPath'))).rejects;
+ await expect(libInstance.addNewPath(path.join(__dirname, 'wrongPath'))).rejects.toThrowError();
expect(eventSpy).toHaveBeenCalled();
expect(eventSpy).toHaveBeenCalledTimes(1);
expect(libInstance.hasPathsProvidedByUser()).toBe(false);
@@ -38,7 +38,7 @@ describe('addNewPath', () => {
/** @test {MediaScan#addNewPath} */
test('existent paths', async () => {
let libInstance = new MediaScan();
- await expect(libInstance.addNewPath(...folders)).resolves;
+ await expect(libInstance.addNewPath(...folders)).resolves.toBeTruthy();
expect(libInstance.hasPathsProvidedByUser()).toBeTruthy();
});
}); |
Thanks : Seems jest-codemods has messup things with AVA way to handle these ... : skovhus/jest-codemods#101 |
I'm sure Kenneth would appreciate an issue about async rejections 🙂 I'm not sure if 101 is directly related |
I just installed jest according to the instructions. And no matter how I run it I get... node:7364) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined |
So Has anyone figured it out yet ? |
Nothing really to figure out. The OP had an error in the code. After that, no reproduction has been posted. Your issue might be #5311 - if not please open up a new issue. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
Bug about Manual Mock
What is the current behavior?
All tests that uses a function
addNewPath
(ie at least 20 of the 29 tests) succeed except 2 for strange reasons ... This function relies on a mock implementation of two modules :fs
andfilehound
If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can
yarn install
andyarn test
.My repo : https://github.com/jy95/mediaScan/tree/test-fix
What is the expected behavior?
It should work
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest version : 22.3.0
Node version : 8.9.3
NPM version : 5.6.0
OS : Windows 10 Version 1709
My jest.config.js :
The text was updated successfully, but these errors were encountered: