Welcome to mirror list, hosted at ThFree Co, Russian Federation.

timeout.spec.js « acceptance « test « mocha-3.1.2 « lib « tests - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b3fc632a0dd1f1d81d3d9ee0f12e3a2fb8ab4c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict';

describe('timeouts', function () {
  beforeEach(function (done) {
    // uncomment
    // setTimeout(done, 3000);
    done();
  });

  it('should error on timeout', function (done) {
    // uncomment
    // setTimeout(done, 3000);
    done();
  });

  it('should allow overriding per-test', function (done) {
    this.timeout(1000);
    setTimeout(function () {
      done();
    }, 300);
  });

  describe('disabling', function () {
    it('should allow overriding per-test', function (done) {
      this.enableTimeouts(false);
      this.timeout(1);
      setTimeout(done, 2);
    });

    it('should work with timeout(0)', function (done) {
      this.timeout(0);
      setTimeout(done, 1);
    });

    describe('using beforeEach', function () {
      beforeEach(function () {
        this.timeout(0);
      });

      it('should work with timeout(0)', function (done) {
        setTimeout(done, 1);
      });
    });

    describe('using before', function () {
      before(function () {
        this.timeout(0);
      });

      it('should work with timeout(0)', function (done) {
        setTimeout(done, 1);
      });
    });

    describe('using enableTimeouts(false)', function () {
      this.timeout(4);

      it('should suppress timeout(4)', function (done) {
        // The test is in the before() call.
        this.enableTimeouts(false);
        setTimeout(done, 50);
      });
    });

    describe('suite-level', function () {
      this.timeout(0);

      it('should work with timeout(0)', function (done) {
        setTimeout(done, 1);
      });

      describe('nested suite', function () {
        it('should work with timeout(0)', function (done) {
          setTimeout(done, 1);
        });
      });
    });
  });
});