summaryrefslogtreecommitdiff
path: root/test/es2017
diff options
context:
space:
mode:
authorPablo Núñez <pablonete@gmail.com>2019-04-08 00:25:07 +0200
committerAlex Early <alexander.early@gmail.com>2019-04-07 15:25:07 -0700
commit4330d536c106592139fa82062494c9dba0da1fdb (patch)
tree6c1120c134349b1375d7bb33ce558fae909e18ec /test/es2017
parenta4c00358cf3c638398735f4006b65e3a82d80ca9 (diff)
downloadasync-4330d536c106592139fa82062494c9dba0da1fdb.tar.gz
chore: Add Azure Pipelines for CI (Windows, Linux, Mac) (#1630), Fix async function serialization in Safari.
* Add azure pipelines CI. * Publish test results. * Enable coveralls * Use Safari for OSX browser tests. * Adding missing lib files to karma (only Safari complained). * Rename with dot so it gets better placed in order. * Use ci instead of install, so we stick with package-lock.json * Use npm test instead of mocha directly. It just needed a double -- escape. * Move DISPLAY to Linux only, with value set just once. * Use variables for DISPLAY, browser tests and coveralls. * Simplify steps with a browser name variable. * Run junit reporter on CI only. * DISPLAY should be already an environment variable. * Use vmImage for consistency with other OS. * Don't use verbose npm@1 task. * No need to setTimeout, let's `done` on the callback. * Don't resume twice. Check queue length on callback for safety, setTimeout may be delayed. * Avoid time dependency, act on events instead. * Avoid dependency on timing to final assertion. * Rewrite test to avoid setTimeout * Fix formatting. * Make diff more significant (125+50 ~= 200) * Make diff more significant to avoid race conditions. * Wait a bit more so default 5 retries did happen. * Make delays shorter to avoid "Timeout of 250ms exceeded" * Shorten delay to avoid 200ms test timeout in browser tests. * Shorten timeout to mitigate 200ms test timeout. * Add more diff on delays to enforce test behavior. * Make delays more significant to avoid race conditions. * Stop using setTimeout and rely on events to push new items, so order is enforced. * Fix async function serialization in Safari. * Add more delay so 4 never completes before 3. * Ensure 3 never completes before 4. * Use drain instead of task count. Trying to ensure done is called from Windows browser tests that fail frequently. * Ensure 2 starts before 3 arrives.Avoid expected 'process 2 3' to equal 'process 2' * Add retries to browser tests. * Don't fail all on Mac & Windows browser tests. * Ensure 3 happens before 2, it fails sparely on OSX. AssertionError: expected [ 1, 2, 3 ] to deeply equal [ 1, 3, 2 ] * Avoid unnecessary multilines. * Use Edge for Windows browser tests.
Diffstat (limited to 'test/es2017')
-rw-r--r--test/es2017/asyncFunctions.js8
-rw-r--r--test/es2017/asyncGenerators.js4
2 files changed, 8 insertions, 4 deletions
diff --git a/test/es2017/asyncFunctions.js b/test/es2017/asyncFunctions.js
index 59c0df8..efb6555 100644
--- a/test/es2017/asyncFunctions.js
+++ b/test/es2017/asyncFunctions.js
@@ -9,6 +9,8 @@ module.exports = function () {
return res;
}
+ this.retries(3);
+
const input = [1, 2, 3];
const inputObj = {a: 1, b: 2, c: 3};
@@ -303,8 +305,8 @@ module.exports = function () {
/* eslint prefer-arrow-callback: 0, object-shorthand: 0 */
it('should handle async functions in autoInject', (done) => {
async.autoInject({
- z: async function(){ return 0},
- a: async function a () {
+ z: async function () { return 0 },
+ a: async function () {
return await Promise.resolve(1);
},
b: async function (a) {
@@ -676,7 +678,7 @@ module.exports = function () {
var fn = async.timeout(async (val) => {
await new Promise((resolve) => setTimeout(resolve, 100));
return val;
- }, 50);
+ }, 20);
fn(1, (err) => {
expect(err.message).to.match(/timed out/);
done();
diff --git a/test/es2017/asyncGenerators.js b/test/es2017/asyncGenerators.js
index c9be07e..61ac964 100644
--- a/test/es2017/asyncGenerators.js
+++ b/test/es2017/asyncGenerators.js
@@ -26,12 +26,14 @@ module.exports = function () {
}
}
+ this.retries(3);
+
it('should handle async generators in each', (done) => {
const calls = []
async.each(range(5),
async (val) => {
calls.push(val)
- await delay(5)
+ await delay(1)
}, (err) => {
if (err) throw err
expect(calls).to.eql([0, 1, 2, 3, 4])