Skip to content

Commit

Permalink
tests: Make logging the resources deterministic
Browse files Browse the repository at this point in the history
The termination of promises is non deterministic, in particular it means we
can't rely on std.log for resource1 to be called before std.log for resource2.

Instead, let's wait for all promises to be resolved and than cycle though their
values to log them to stdout.
  • Loading branch information
dlespiau committed Mar 5, 2019
1 parent 802cb42 commit 717f141
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tests/test-module-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import std from '@jkcfg/std';
import resource1 from './test-module-resource/resource';
import resource2 from './test-module-resource/submodule/resource';

resource1.then(std.log);
resource2.then(std.log);
Promise.all([resource1, resource2]).then(resources => resources.forEach(std.log))

0 comments on commit 717f141

Please sign in to comment.