Skip to content
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

afterAll hide errors #9882

Closed
evandrocoan opened this issue Apr 25, 2020 · 13 comments
Closed

afterAll hide errors #9882

evandrocoan opened this issue Apr 25, 2020 · 13 comments

Comments

@evandrocoan
Copy link

evandrocoan commented Apr 25, 2020

🐛 Bug Report

https://repl.it/@evandrocoan/EnviousMagnificentApplicationpackage

const sum = require('./sum');

describe("Test question and answer audios", () => {
  beforeAll(async () => {
    console.log("beforeAll");
  });

  afterAll(async () => {
    console.supererror();
    console.log("afterAll");
  });

  test('Timeout on the wrong place...', async () => {
    expect(sum(1, 2)).toBe(3);
  });
});

Actual behavior

jest
 PASS  ./sum.test.js
  Test question and answer audiosTimeout on the wrong place... (5ms)

  console.log sum.test.js:5
    beforeAll

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        6.199s
Ran all test suites.

Expected behavior

jest
 FAIL  ./sum.test.js
  Test question and answer audiosTimeout on the wrong place... (3ms)

  ● Test question and answer audiosTimeout on the wrong place...

    TypeError: console.supererror is not a function

       7 | 
       8 |   afterAll(async () => {
    >  9 |     console.supererror();
         |             ^
      10 |     console.log("afterAll");
      11 |   });
      12 | 

      at Object.<anonymous> (sum.test.js:9:13)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        6.657s
Ran all test suites.
exit status 1

envinfo

npx envinfo --preset jest
npx: installed 1 in 4.22s

  System:
    OS: Linux 4.15 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (4) x64 Intel(R) Xeon(R) CPU @ 2.30GHz
  Binaries:
    Node: 12.16.2 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.9.0 => 24.9.0 

Related:

  1. afterAll hook hides errors. afterAll hook hides errors. #3266
  2. afterAll inside a describe hides errors afterAll inside a describe hides errors #6692
  3. beforeAll() executed in parallel with test case in case of timeout beforeAll() executed in parallel with test case in case of timeout #9527
  4. A timeout in a beforeEach continues executing the dependant test cases A timeout in a beforeEach continues executing the dependant test cases #8442
  5. beforeAll async hook hides errors beforeAll async hook hides errors #8688
@SimenB
Copy link
Member

SimenB commented May 8, 2020

@evandrocoan I cannot reproduce this. Running the repl you provide it looks like what you outline in "Expected behavior".

image

If you meant to have the error in afterAll instead I can reproduce using jest-jasmine (default), but it's fixed with jest-circus, which will become the default in Jest 27.

image

Can you confirm?

@evandrocoan
Copy link
Author

evandrocoan commented May 8, 2020

Yes. The code I had on Repl.it was different from the code I have here on the first post. I think I changed it on Repl.it thinking it was another Repl.it. The correct code is this:

const sum = require('./sum');

describe("Test question and answer audios", () => {
  afterAll(async () => {
    console.zupererror();
    console.log("afterAll");
  });

  beforeAll(async () => {
    console.log("beforeAll");
  });

  test('Timeout on the wrong place...', async () => {
    expect(sum(1, 2)).toBe(3);
  });
});

Which has an error on the afterAll() but the error is hidden:

image

@chasen-bettinger
Copy link

Why was this closed?

@evandrocoan
Copy link
Author

Because he said it will be fixed:

If you meant to have the error in afterAll instead I can reproduce using jest-jasmine (default), but it's fixed with jest-circus, which will become the default in Jest 27.

But I am reopening it until the fix is actually released.

@evandrocoan evandrocoan reopened this May 27, 2020
@chasen-bettinger
Copy link

Because he said it will be fixed:

If you meant to have the error in afterAll instead I can reproduce using jest-jasmine (default), but it's fixed with jest-circus, which will become the default in Jest 27.

But I am reopening it until the fix is actually released.

Thanks, I was confused because another thread said circus was going to be default in 25. Was elegantly surprised to see that jasmine was still the default in 26.

I can personally report that jest-circus has fixed this issue for me.

@jayarjo
Copy link

jayarjo commented May 28, 2020

Related: #9368

@jayarjo
Copy link

jayarjo commented May 28, 2020

So what would be the procedure to fix this behavior at the moment? @chasen-bettinger mind to share? Do I simply need to install jest-circus?

@chasen-bettinger
Copy link

@jayarjo

Follow the Installation and Configuration steps here: https://www.npmjs.com/package/jest-circus

@serverlesspolska

This comment has been minimized.

@SimenB
Copy link
Member

SimenB commented Nov 6, 2020

feel free to send a PR. Or use jest-cricus - it will be default in 27: #10686

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Feb 17, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2023
@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants