joeljeske / karma-parallel

A Karma JS Framework to support sharding tests to run in parallel across multiple browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

afterAll() is executed in all parallel executors insted of being executed only in the executor running the spec

brannislav opened this issue · comments

**I'm submitting a ... **

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?
When config.parallelOptions.executors is > 1 the afterAll() functions of tests are called in all executors.
Adding a console.log in the afterAll will confirm this behavior.

What is the expected behavior?
afterAll() function should be called only for one of the executors in which the whole spec is executed.

What is the motivation / use case for changing the behavior?
We have a few tests that do cleanup in afterAll() but when run in parallel they started failing with TypeError:

"An error was thrown in afterAll\nTypeError: Cannot read property 'destroy' of undefined\n"

After debugging the issue it tuns out that the beforeAll for those tests was not called in most executors but one.

Also it is worth mentioning that this issue remained hidden for some time before older versions of Jasmine did not fail the tests if exception was thrown in the afterAll().
We recently bumped Jasmine to 2.8.0 and than this issue manifested itself.

Please tell us about your environment:

  • version: 0.2.4
  • Jasmine 2.8.0, Karma 2.0.0
  • Browser: [Chrome 64.0.3282.186]
  • Language: [TypeScript 2.0]
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

It seems this was a copy-paste issue because in:

ctx.before = wrap(ctx.before, false, false, false);
ctx.beforeAll = wrap(ctx.beforeAll, false, false, false);
ctx.beforeEach = wrap(ctx.beforeEach, false, false, false);
ctx.beforeAll = wrap(ctx.beforeAll, false, false, false);
ctx.after = wrap(ctx.after, false, false, false);
ctx.afterEach = wrap(ctx.afterEach, false, false, false);

beforeAll is duplicated and afterAll is missing. I tried doing the fix locally and can confirm that is adding beforeAll fixes the issue.

Awesome. Merged and published. Thanks for tracking this down.