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

When using --forceExit, jest will ignore afterAll #2981

Closed
samijaber opened this issue Feb 22, 2017 · 2 comments
Closed

When using --forceExit, jest will ignore afterAll #2981

samijaber opened this issue Feb 22, 2017 · 2 comments

Comments

@samijaber
Copy link

if I call jest while passing the forceExit flag, it will exit before executing any afterAll blocks. Here is an example:

describe('test', () => {
  afterAll(() => {
    console.log('after All');
  });
  
  describe('/', () => {
    it('a', (done) => {
      ...
    });

    it('b', (done) => {
      ...
    });
  });
});

The afterAll will never be reached in this example. It should execute any pending afterAlls before forcing an exit.

@cpojer
Copy link
Member

cpojer commented Feb 25, 2017

This is kind of an odd problem. --forceExit exists so that Jest kills your tests and exits if you aren't cleaning up your resources properly. If you change afterAll to properly tear down your handlers, you won't need forceExit.

@cpojer cpojer closed this as completed Feb 25, 2017
atodorov added a commit to atodorov/welder-web that referenced this issue Apr 3, 2018
also remove --forceExit from jest options because this causes
afterAll not to be executed, see:
jestjs/jest#2981
atodorov added a commit to atodorov/welder-web that referenced this issue Apr 5, 2018
also remove --forceExit from jest options because this causes
afterAll not to be executed, see:
jestjs/jest#2981
atodorov added a commit to atodorov/welder-web that referenced this issue Apr 24, 2018
also remove --forceExit from jest options because this causes
afterAll not to be executed, see:
jestjs/jest#2981
@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 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants