mardi 2 mars 2021

Are dart2js browser tests ran in parallel and if so, what is the unit of parallelism?

I recently ran into a problem where I had a bunch of tests that interact with browser's (chromium) LocalStorage within a group. This should give you an idea what I mean:

group('some-group', () {
  const storageKey = 'some-key';
  setUp(() {
    window.localStorage.remove(storageKey);  
  });
  test('first', () async {
    await functionThatWritesToLocalstorage('param');
    expect(window.localStorage[storageKey], 'param');
  });
  test('first', () async {
    await functionThatWritesToLocalstorage('param2');
    expect(window.localStorage[storageKey], 'param2');
  });
});

What I observed was that on the CI there was a certain level of flakyness to these tests. When I declare parallelism to tests with pub run build_runner test -- -p chrome --concurrency=4 tests sometimes fail.

Q: are individual test ran in parallel, or maybe groups or is concurrency limited to _test.dart files?

(I suspect that somehow there is a write to local storage while tests are blocked by await)

Thanks!

Aucun commentaire:

Enregistrer un commentaire