Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 4x 4x 238x 238x 238x 238x 238x 238x 238x 238x 4x 210x 209x 209x 4x 208x 207x 207x 4x 445x 445x 445x 445x 445x 4x 536x 534x 4x 222x 4x 1x 4x 1x 4x 1x 4x 2x 4x 532x 4x 4x 4x 4x 4x 266x 266x 4x | "use strict"; /** * Contains classes and functions to save executed tests data. * * @module */ var expect = require("chai").expect; /** * Test case data structure. * * Contains full information and history about test case. * * @class * @arg {string} name - Test name. * @prop {string} name - Test name. * @prop {string} [status=NOT_STARTED] - Test status. * @prop {?string} [skipChunk=null] - Name of currently skipped chunk. * @prop {string[]} [screenshots=[]] - List of test screenshot paths. * @prop {string[]} [videos=[]] - List of test video paths. * @prop {string[]} [errors=[]] - List of test errors. * @prop {string[]} [rawInfo=[]] - List of additional test details. * @prop {object} [testParams={}] - Dict of test parameters. */ var TestCase = module.exports.TestCase = function (name, id) { this.duration = 0; this.name = name; this.id = id; this.status = TestCase.NOT_STARTED; this.skipChunk = null; this.chunks = []; this.passedChunkIds = []; this.reset(); }; /** * Starts test case. * * @method */ TestCase.prototype.start = function () { expect(this.status, `test case '${this.name}' is started already`) .to.not.be.equal(TestCase.IN_PROGRESS); this._startTime = new Date(); this.status = TestCase.IN_PROGRESS; }; /** * Ends test case. * * @method * @arg {string} status - Test case status. */ TestCase.prototype.end = function (status) { expect(this.status, `test case '${this.name}' isn't started yet`) .to.be.equal(TestCase.IN_PROGRESS); this.duration += new Date() - this._startTime; this.status = status; }; /** * Resets test case info. * * @method */ TestCase.prototype.reset = function () { this.screenshots = []; this.videos = []; this.errors = []; this.rawInfo = []; this.testParams = {}; }; /** * Adds passed chunk id. * * @method * @arg {string} chunkId - Chunk id. */ TestCase.prototype.addPassedChunkId = function (chunkId) { if (!chunkId || this.passedChunkIds.includes(chunkId)) return; this.passedChunkIds.push(chunkId); }; /** * Adds passed chunk ids. * * @method * @arg {array<string>} chunkIds - Chunk ids. */ TestCase.prototype.addPassedChunkIds = function (chunkIds) { for (const chunkId of chunkIds) this.addPassedChunkId(chunkId); }; /** * Adds error to test case. * * @method * @arg {Error} err - Test error. */ TestCase.prototype.addError = function (err) { this.errors.push(err); }; /** * Adds screenshot. * * @method * @arg {string} imagePath - Path to saved screenshot. */ TestCase.prototype.addScreenshot = function (imagePath) { this.screenshots.push(imagePath); }; /** * Adds video. * * @method * @arg {string} videoPath - Path to saved video. */ TestCase.prototype.addVideo = function (videoPath) { this.videos.push(videoPath); }; /** * Adds additional information. * * @method * @arg {string} info - Additional information. */ TestCase.prototype.addDetails = function (info) { this.rawInfo.push(info); }; /** * Adds chunk. * * @method * @arg {string} chunkName - Name of chunk. */ TestCase.prototype.addChunk = function (chunkName) { this.chunks.push(chunkName); }; TestCase.NOT_STARTED = "not started"; TestCase.IN_PROGRESS = "in progress"; TestCase.FAILED = "failed"; TestCase.PASSED = "passed"; TestCase.SKIPPED = "skipped"; /** * Class defining mochajs scope name and type. */ class ScopeType extends String { /** * Set mochajs scope type. * @arg {string} type - Supported values are `scope`, `suite`, `test`. */ setType (type) { this.type = type; return this; } }; module.exports.ScopeType = ScopeType; |