jasmine-core 2.99.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jasmine-core/boot.js +7 -6
- data/lib/jasmine-core/boot/boot.js +7 -6
- data/lib/jasmine-core/boot/node_boot.js +0 -3
- data/lib/jasmine-core/jasmine-html.js +228 -137
- data/lib/jasmine-core/jasmine.css +11 -5
- data/lib/jasmine-core/jasmine.js +1046 -608
- data/lib/jasmine-core/node_boot.js +0 -3
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +130 -0
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +137 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +710 -0
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +286 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +200 -0
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +120 -0
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +46 -0
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +434 -0
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +110 -0
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +259 -0
- data/lib/jasmine-core/spec/core/MockDateSpec.js +200 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +332 -0
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +670 -0
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +140 -0
- data/lib/jasmine-core/spec/core/SpecSpec.js +407 -0
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +364 -0
- data/lib/jasmine-core/spec/core/SpySpec.js +177 -0
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +202 -0
- data/lib/jasmine-core/spec/core/StackTraceSpec.js +166 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +123 -0
- data/lib/jasmine-core/spec/core/TimerSpec.js +31 -0
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +794 -0
- data/lib/jasmine-core/spec/core/UserContextSpec.js +54 -0
- data/lib/jasmine-core/spec/core/UtilSpec.js +105 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +91 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +76 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +52 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +47 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +99 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +27 -0
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +13 -0
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +200 -0
- data/lib/jasmine-core/spec/core/integration/CustomSpyStrategiesSpec.js +138 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +2344 -0
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +976 -0
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +645 -0
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +8 -0
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +93 -0
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +18 -0
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +29 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +37 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -0
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +18 -0
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +26 -0
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +785 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +47 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +86 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +67 -0
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +43 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +315 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowMatchingSpec.js +73 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +100 -0
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +15 -0
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +27 -0
- data/lib/jasmine-core/spec/helpers/checkForMap.js +37 -0
- data/lib/jasmine-core/spec/helpers/checkForSet.js +41 -0
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +20 -0
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +6 -0
- data/lib/jasmine-core/spec/helpers/integrationMatchers.js +43 -0
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +30 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +1261 -0
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +37 -0
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +27 -0
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +72 -0
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +39 -0
- data/lib/jasmine-core/spec/html/matchers/toHaveClassSpec.js +48 -0
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +101 -0
- data/lib/jasmine-core/spec/performance/large_object_test.js +36 -0
- data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
- data/lib/jasmine-core/version.rb +1 -1
- metadata +88 -4
- data/lib/console/console.js +0 -190
@@ -0,0 +1,976 @@
|
|
1
|
+
describe("spec running", function () {
|
2
|
+
var env;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
jasmine.getEnv().registerIntegrationMatchers();
|
6
|
+
env = new jasmineUnderTest.Env();
|
7
|
+
env.randomizeTests(false);
|
8
|
+
});
|
9
|
+
|
10
|
+
it('should assign spec ids sequentially', function() {
|
11
|
+
var it0, it1, it2, it3, it4;
|
12
|
+
env.describe('test suite', function() {
|
13
|
+
it0 = env.it('spec 0', function() {
|
14
|
+
});
|
15
|
+
it1 = env.it('spec 1', function() {
|
16
|
+
});
|
17
|
+
it2 = env.xit('spec 2', function() {
|
18
|
+
});
|
19
|
+
it3 = env.it('spec 3', function() {
|
20
|
+
});
|
21
|
+
});
|
22
|
+
env.describe('test suite 2', function() {
|
23
|
+
it4 = env.it('spec 4', function() {
|
24
|
+
});
|
25
|
+
});
|
26
|
+
|
27
|
+
expect(it0.id).toEqual('spec0');
|
28
|
+
expect(it1.id).toEqual('spec1');
|
29
|
+
expect(it2.id).toEqual('spec2');
|
30
|
+
expect(it3.id).toEqual('spec3');
|
31
|
+
expect(it4.id).toEqual('spec4');
|
32
|
+
});
|
33
|
+
|
34
|
+
it('nested suites', function (done) {
|
35
|
+
|
36
|
+
var foo = 0;
|
37
|
+
var bar = 0;
|
38
|
+
var baz = 0;
|
39
|
+
var quux = 0;
|
40
|
+
var nested = env.describe('suite', function () {
|
41
|
+
env.describe('nested', function () {
|
42
|
+
env.it('should run nested suites', function () {
|
43
|
+
foo++;
|
44
|
+
});
|
45
|
+
env.it('should run nested suites', function () {
|
46
|
+
bar++;
|
47
|
+
});
|
48
|
+
});
|
49
|
+
|
50
|
+
env.describe('nested 2', function () {
|
51
|
+
env.it('should run suites following nested suites', function () {
|
52
|
+
baz++;
|
53
|
+
});
|
54
|
+
});
|
55
|
+
|
56
|
+
env.it('should run tests following nested suites', function () {
|
57
|
+
quux++;
|
58
|
+
});
|
59
|
+
});
|
60
|
+
|
61
|
+
expect(foo).toEqual(0);
|
62
|
+
expect(bar).toEqual(0);
|
63
|
+
expect(baz).toEqual(0);
|
64
|
+
expect(quux).toEqual(0);
|
65
|
+
var assertions = function() {
|
66
|
+
expect(foo).toEqual(1);
|
67
|
+
expect(bar).toEqual(1);
|
68
|
+
expect(baz).toEqual(1);
|
69
|
+
expect(quux).toEqual(1);
|
70
|
+
done();
|
71
|
+
};
|
72
|
+
|
73
|
+
env.addReporter({ jasmineDone: assertions });
|
74
|
+
|
75
|
+
env.execute();
|
76
|
+
});
|
77
|
+
|
78
|
+
it("should permit nested describes", function(done) {
|
79
|
+
var actions = [];
|
80
|
+
|
81
|
+
env.beforeEach(function () {
|
82
|
+
actions.push('topSuite beforeEach');
|
83
|
+
});
|
84
|
+
|
85
|
+
env.afterEach(function () {
|
86
|
+
actions.push('topSuite afterEach');
|
87
|
+
});
|
88
|
+
|
89
|
+
env.describe('Something', function() {
|
90
|
+
env.beforeEach(function() {
|
91
|
+
actions.push('outer beforeEach');
|
92
|
+
});
|
93
|
+
|
94
|
+
env.afterEach(function() {
|
95
|
+
actions.push('outer afterEach');
|
96
|
+
});
|
97
|
+
|
98
|
+
env.it('does it 1', function() {
|
99
|
+
actions.push('outer it 1');
|
100
|
+
});
|
101
|
+
|
102
|
+
env.describe('Inner 1', function() {
|
103
|
+
env.beforeEach(function() {
|
104
|
+
actions.push('inner 1 beforeEach');
|
105
|
+
});
|
106
|
+
|
107
|
+
env.afterEach(function() {
|
108
|
+
actions.push('inner 1 afterEach');
|
109
|
+
});
|
110
|
+
|
111
|
+
env.it('does it 2', function() {
|
112
|
+
actions.push('inner 1 it');
|
113
|
+
});
|
114
|
+
});
|
115
|
+
|
116
|
+
env.it('does it 3', function() {
|
117
|
+
actions.push('outer it 2');
|
118
|
+
});
|
119
|
+
|
120
|
+
env.describe('Inner 2', function() {
|
121
|
+
env.beforeEach(function() {
|
122
|
+
actions.push('inner 2 beforeEach');
|
123
|
+
});
|
124
|
+
|
125
|
+
env.afterEach(function() {
|
126
|
+
actions.push('inner 2 afterEach');
|
127
|
+
});
|
128
|
+
|
129
|
+
env.it('does it 2', function() {
|
130
|
+
actions.push('inner 2 it');
|
131
|
+
});
|
132
|
+
});
|
133
|
+
});
|
134
|
+
|
135
|
+
var assertions = function() {
|
136
|
+
var expected = [
|
137
|
+
"topSuite beforeEach",
|
138
|
+
"outer beforeEach",
|
139
|
+
"outer it 1",
|
140
|
+
"outer afterEach",
|
141
|
+
"topSuite afterEach",
|
142
|
+
|
143
|
+
"topSuite beforeEach",
|
144
|
+
"outer beforeEach",
|
145
|
+
"inner 1 beforeEach",
|
146
|
+
"inner 1 it",
|
147
|
+
"inner 1 afterEach",
|
148
|
+
"outer afterEach",
|
149
|
+
"topSuite afterEach",
|
150
|
+
|
151
|
+
"topSuite beforeEach",
|
152
|
+
"outer beforeEach",
|
153
|
+
"outer it 2",
|
154
|
+
"outer afterEach",
|
155
|
+
"topSuite afterEach",
|
156
|
+
|
157
|
+
"topSuite beforeEach",
|
158
|
+
"outer beforeEach",
|
159
|
+
"inner 2 beforeEach",
|
160
|
+
"inner 2 it",
|
161
|
+
"inner 2 afterEach",
|
162
|
+
"outer afterEach",
|
163
|
+
"topSuite afterEach"
|
164
|
+
];
|
165
|
+
expect(actions).toEqual(expected);
|
166
|
+
done();
|
167
|
+
};
|
168
|
+
|
169
|
+
env.addReporter({jasmineDone: assertions});
|
170
|
+
|
171
|
+
env.execute();
|
172
|
+
});
|
173
|
+
|
174
|
+
it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
|
175
|
+
var actions = [];
|
176
|
+
|
177
|
+
env.beforeAll(function() {
|
178
|
+
actions.push('runner beforeAll1');
|
179
|
+
});
|
180
|
+
|
181
|
+
env.afterAll(function() {
|
182
|
+
actions.push('runner afterAll1');
|
183
|
+
});
|
184
|
+
|
185
|
+
env.beforeAll(function() {
|
186
|
+
actions.push('runner beforeAll2');
|
187
|
+
});
|
188
|
+
|
189
|
+
env.afterAll(function() {
|
190
|
+
actions.push('runner afterAll2');
|
191
|
+
});
|
192
|
+
|
193
|
+
env.beforeEach(function () {
|
194
|
+
actions.push('runner beforeEach1');
|
195
|
+
});
|
196
|
+
|
197
|
+
env.afterEach(function () {
|
198
|
+
actions.push('runner afterEach1');
|
199
|
+
});
|
200
|
+
|
201
|
+
env.beforeEach(function () {
|
202
|
+
actions.push('runner beforeEach2');
|
203
|
+
});
|
204
|
+
|
205
|
+
env.afterEach(function () {
|
206
|
+
actions.push('runner afterEach2');
|
207
|
+
});
|
208
|
+
|
209
|
+
env.describe('Something', function() {
|
210
|
+
env.beforeEach(function() {
|
211
|
+
actions.push('beforeEach1');
|
212
|
+
});
|
213
|
+
|
214
|
+
env.afterEach(function() {
|
215
|
+
actions.push('afterEach1');
|
216
|
+
});
|
217
|
+
|
218
|
+
env.beforeEach(function() {
|
219
|
+
actions.push('beforeEach2');
|
220
|
+
});
|
221
|
+
|
222
|
+
env.afterEach(function() {
|
223
|
+
actions.push('afterEach2');
|
224
|
+
});
|
225
|
+
|
226
|
+
env.it('does it 1', function() {
|
227
|
+
actions.push('outer it 1');
|
228
|
+
});
|
229
|
+
});
|
230
|
+
|
231
|
+
var assertions = function() {
|
232
|
+
var expected = [
|
233
|
+
"runner beforeAll1",
|
234
|
+
"runner beforeAll2",
|
235
|
+
"runner beforeEach1",
|
236
|
+
"runner beforeEach2",
|
237
|
+
"beforeEach1",
|
238
|
+
"beforeEach2",
|
239
|
+
"outer it 1",
|
240
|
+
"afterEach2",
|
241
|
+
"afterEach1",
|
242
|
+
"runner afterEach2",
|
243
|
+
"runner afterEach1",
|
244
|
+
"runner afterAll2",
|
245
|
+
"runner afterAll1"
|
246
|
+
];
|
247
|
+
expect(actions).toEqual(expected);
|
248
|
+
done();
|
249
|
+
};
|
250
|
+
|
251
|
+
env.addReporter({jasmineDone: assertions});
|
252
|
+
|
253
|
+
env.execute();
|
254
|
+
});
|
255
|
+
|
256
|
+
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {
|
257
|
+
var actions = [];
|
258
|
+
|
259
|
+
env.beforeAll(function() {
|
260
|
+
actions.push('runner beforeAll');
|
261
|
+
});
|
262
|
+
|
263
|
+
env.afterAll(function() {
|
264
|
+
actions.push('runner afterAll');
|
265
|
+
});
|
266
|
+
|
267
|
+
env.beforeEach(function () {
|
268
|
+
actions.push('runner beforeEach');
|
269
|
+
});
|
270
|
+
|
271
|
+
env.afterEach(function () {
|
272
|
+
actions.push('runner afterEach');
|
273
|
+
});
|
274
|
+
|
275
|
+
env.describe('Something', function() {
|
276
|
+
env.beforeEach(function() {
|
277
|
+
actions.push('inner beforeEach');
|
278
|
+
});
|
279
|
+
|
280
|
+
env.afterEach(function() {
|
281
|
+
actions.push('inner afterEach');
|
282
|
+
});
|
283
|
+
|
284
|
+
env.beforeAll(function() {
|
285
|
+
actions.push('inner beforeAll');
|
286
|
+
});
|
287
|
+
|
288
|
+
env.afterAll(function() {
|
289
|
+
actions.push('inner afterAll');
|
290
|
+
});
|
291
|
+
|
292
|
+
env.it('does something or other', function() {
|
293
|
+
actions.push('it');
|
294
|
+
});
|
295
|
+
});
|
296
|
+
|
297
|
+
var assertions = function() {
|
298
|
+
var expected = [
|
299
|
+
"runner beforeAll",
|
300
|
+
"inner beforeAll",
|
301
|
+
"runner beforeEach",
|
302
|
+
"inner beforeEach",
|
303
|
+
"it",
|
304
|
+
"inner afterEach",
|
305
|
+
"runner afterEach",
|
306
|
+
"inner afterAll",
|
307
|
+
"runner afterAll"
|
308
|
+
];
|
309
|
+
expect(actions).toEqual(expected);
|
310
|
+
done();
|
311
|
+
};
|
312
|
+
|
313
|
+
env.addReporter({jasmineDone: assertions});
|
314
|
+
env.execute();
|
315
|
+
});
|
316
|
+
|
317
|
+
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {
|
318
|
+
var actions = [],
|
319
|
+
spec,
|
320
|
+
spec2;
|
321
|
+
|
322
|
+
env.beforeAll(function() {
|
323
|
+
actions.push('runner beforeAll');
|
324
|
+
});
|
325
|
+
|
326
|
+
env.afterAll(function() {
|
327
|
+
actions.push('runner afterAll');
|
328
|
+
});
|
329
|
+
|
330
|
+
env.beforeEach(function () {
|
331
|
+
actions.push('runner beforeEach');
|
332
|
+
});
|
333
|
+
|
334
|
+
env.afterEach(function () {
|
335
|
+
actions.push('runner afterEach');
|
336
|
+
});
|
337
|
+
|
338
|
+
env.describe('Something', function() {
|
339
|
+
env.beforeEach(function() {
|
340
|
+
actions.push('inner beforeEach');
|
341
|
+
});
|
342
|
+
|
343
|
+
env.afterEach(function() {
|
344
|
+
actions.push('inner afterEach');
|
345
|
+
});
|
346
|
+
|
347
|
+
env.beforeAll(function() {
|
348
|
+
actions.push('inner beforeAll');
|
349
|
+
});
|
350
|
+
|
351
|
+
env.afterAll(function() {
|
352
|
+
actions.push('inner afterAll');
|
353
|
+
});
|
354
|
+
|
355
|
+
spec = env.it('does something', function() {
|
356
|
+
actions.push('it');
|
357
|
+
});
|
358
|
+
|
359
|
+
spec2 = env.it('does something or other', function() {
|
360
|
+
actions.push('it2');
|
361
|
+
});
|
362
|
+
});
|
363
|
+
|
364
|
+
var assertions = function() {
|
365
|
+
var expected = [
|
366
|
+
"runner beforeAll",
|
367
|
+
"inner beforeAll",
|
368
|
+
"runner beforeEach",
|
369
|
+
"inner beforeEach",
|
370
|
+
"it2",
|
371
|
+
"inner afterEach",
|
372
|
+
"runner afterEach",
|
373
|
+
|
374
|
+
"runner beforeEach",
|
375
|
+
"inner beforeEach",
|
376
|
+
"it",
|
377
|
+
"inner afterEach",
|
378
|
+
"runner afterEach",
|
379
|
+
"inner afterAll",
|
380
|
+
"runner afterAll"
|
381
|
+
];
|
382
|
+
expect(actions).toEqual(expected);
|
383
|
+
done();
|
384
|
+
};
|
385
|
+
|
386
|
+
env.addReporter({jasmineDone: assertions});
|
387
|
+
env.execute([spec2.id, spec.id]);
|
388
|
+
});
|
389
|
+
|
390
|
+
it('only runs *Alls once in a focused suite', function(done){
|
391
|
+
var actions = [];
|
392
|
+
|
393
|
+
env.fdescribe('Suite', function() {
|
394
|
+
env.beforeAll(function(){
|
395
|
+
actions.push('beforeAll');
|
396
|
+
});
|
397
|
+
env.it('should run beforeAll once', function() {
|
398
|
+
actions.push('spec');
|
399
|
+
});
|
400
|
+
env.afterAll(function(){
|
401
|
+
actions.push('afterAll');
|
402
|
+
});
|
403
|
+
});
|
404
|
+
|
405
|
+
var assertions = function() {
|
406
|
+
expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);
|
407
|
+
done();
|
408
|
+
};
|
409
|
+
|
410
|
+
env.addReporter({jasmineDone: assertions});
|
411
|
+
env.execute();
|
412
|
+
});
|
413
|
+
|
414
|
+
describe('focused runnables', function() {
|
415
|
+
it('runs the relevant alls and eachs for each runnable', function(done) {
|
416
|
+
var actions = [];
|
417
|
+
env.beforeAll(function() {actions.push('beforeAll')});
|
418
|
+
env.afterAll(function() {actions.push('afterAll')});
|
419
|
+
env.beforeEach(function() {actions.push('beforeEach')});
|
420
|
+
env.afterEach(function() {actions.push('afterEach')});
|
421
|
+
|
422
|
+
env.fdescribe('a focused suite', function() {
|
423
|
+
env.it('is run', function() {
|
424
|
+
actions.push('spec in fdescribe')
|
425
|
+
});
|
426
|
+
});
|
427
|
+
|
428
|
+
env.describe('an unfocused suite', function() {
|
429
|
+
env.fit('has a focused spec', function() {
|
430
|
+
actions.push('focused spec')
|
431
|
+
});
|
432
|
+
});
|
433
|
+
|
434
|
+
var assertions = function() {
|
435
|
+
var expected = [
|
436
|
+
'beforeAll',
|
437
|
+
'beforeEach',
|
438
|
+
'spec in fdescribe',
|
439
|
+
'afterEach',
|
440
|
+
|
441
|
+
'beforeEach',
|
442
|
+
'focused spec',
|
443
|
+
'afterEach',
|
444
|
+
'afterAll'
|
445
|
+
];
|
446
|
+
expect(actions).toEqual(expected);
|
447
|
+
done();
|
448
|
+
};
|
449
|
+
|
450
|
+
env.addReporter({jasmineDone: assertions});
|
451
|
+
env.execute();
|
452
|
+
});
|
453
|
+
|
454
|
+
it('focused specs in focused suites cause non-focused siblings to not run', function(done){
|
455
|
+
var actions = [];
|
456
|
+
|
457
|
+
env.fdescribe('focused suite', function() {
|
458
|
+
env.it('unfocused spec', function() {
|
459
|
+
actions.push('unfocused spec')
|
460
|
+
});
|
461
|
+
env.fit('focused spec', function() {
|
462
|
+
actions.push('focused spec')
|
463
|
+
});
|
464
|
+
});
|
465
|
+
|
466
|
+
var assertions = function() {
|
467
|
+
var expected = ['focused spec'];
|
468
|
+
expect(actions).toEqual(expected);
|
469
|
+
done();
|
470
|
+
};
|
471
|
+
|
472
|
+
env.addReporter({jasmineDone: assertions});
|
473
|
+
env.execute();
|
474
|
+
});
|
475
|
+
|
476
|
+
it('focused suites in focused suites cause non-focused siblings to not run', function(done){
|
477
|
+
var actions = [];
|
478
|
+
|
479
|
+
env.fdescribe('focused suite', function() {
|
480
|
+
env.it('unfocused spec', function() {
|
481
|
+
actions.push('unfocused spec')
|
482
|
+
});
|
483
|
+
env.fdescribe('inner focused suite', function() {
|
484
|
+
env.it('inner spec', function() {
|
485
|
+
actions.push('inner spec');
|
486
|
+
});
|
487
|
+
});
|
488
|
+
});
|
489
|
+
|
490
|
+
var assertions = function() {
|
491
|
+
var expected = ['inner spec'];
|
492
|
+
expect(actions).toEqual(expected);
|
493
|
+
done();
|
494
|
+
};
|
495
|
+
|
496
|
+
env.addReporter({jasmineDone: assertions});
|
497
|
+
env.execute();
|
498
|
+
});
|
499
|
+
|
500
|
+
it('focused runnables unfocus ancestor focused suites', function(done) {
|
501
|
+
var actions = [];
|
502
|
+
|
503
|
+
env.fdescribe('focused suite', function() {
|
504
|
+
env.it('unfocused spec', function() {
|
505
|
+
actions.push('unfocused spec')
|
506
|
+
});
|
507
|
+
env.describe('inner focused suite', function() {
|
508
|
+
env.fit('focused spec', function() {
|
509
|
+
actions.push('focused spec');
|
510
|
+
});
|
511
|
+
});
|
512
|
+
});
|
513
|
+
|
514
|
+
var assertions = function() {
|
515
|
+
var expected = ['focused spec'];
|
516
|
+
expect(actions).toEqual(expected);
|
517
|
+
done();
|
518
|
+
};
|
519
|
+
|
520
|
+
env.addReporter({jasmineDone: assertions});
|
521
|
+
env.execute();
|
522
|
+
});
|
523
|
+
});
|
524
|
+
|
525
|
+
it("shouldn't run disabled suites", function(done) {
|
526
|
+
var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
|
527
|
+
suite = env.describe('A Suite', function() {
|
528
|
+
env.xdescribe('with a disabled suite', function(){
|
529
|
+
env.it('spec inside a disabled suite', specInADisabledSuite);
|
530
|
+
});
|
531
|
+
});
|
532
|
+
|
533
|
+
var assertions = function() {
|
534
|
+
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
535
|
+
done();
|
536
|
+
};
|
537
|
+
|
538
|
+
env.addReporter({jasmineDone: assertions});
|
539
|
+
|
540
|
+
env.execute();
|
541
|
+
});
|
542
|
+
|
543
|
+
it("shouldn't run before/after functions in disabled suites", function(done) {
|
544
|
+
var shouldNotRun = jasmine.createSpy("shouldNotRun"),
|
545
|
+
suite = env.xdescribe('A disabled Suite', function() {
|
546
|
+
// None of the before/after functions should run.
|
547
|
+
env.beforeAll(shouldNotRun);
|
548
|
+
env.beforeEach(shouldNotRun);
|
549
|
+
env.afterEach(shouldNotRun);
|
550
|
+
env.afterAll(shouldNotRun);
|
551
|
+
|
552
|
+
env.it('spec inside a disabled suite', shouldNotRun);
|
553
|
+
});
|
554
|
+
|
555
|
+
var assertions = function() {
|
556
|
+
expect(shouldNotRun).not.toHaveBeenCalled();
|
557
|
+
done();
|
558
|
+
};
|
559
|
+
|
560
|
+
env.addReporter({jasmineDone: assertions});
|
561
|
+
|
562
|
+
env.execute();
|
563
|
+
});
|
564
|
+
|
565
|
+
it("should allow top level suites to be disabled", function(done) {
|
566
|
+
var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),
|
567
|
+
otherSpec = jasmine.createSpy("otherSpec");
|
568
|
+
|
569
|
+
env.xdescribe('A disabled suite', function() {
|
570
|
+
env.it('spec inside a disabled suite', specInADisabledSuite);
|
571
|
+
});
|
572
|
+
env.describe('Another suite', function() {
|
573
|
+
env.it('another spec', otherSpec);
|
574
|
+
});
|
575
|
+
|
576
|
+
var assertions = function() {
|
577
|
+
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
578
|
+
expect(otherSpec).toHaveBeenCalled();
|
579
|
+
done();
|
580
|
+
};
|
581
|
+
|
582
|
+
env.addReporter({jasmineDone: assertions});
|
583
|
+
|
584
|
+
env.execute();
|
585
|
+
});
|
586
|
+
|
587
|
+
it("should set all pending specs to pending when a suite is run", function(done) {
|
588
|
+
var pendingSpec,
|
589
|
+
suite = env.describe('default current suite', function() {
|
590
|
+
pendingSpec = env.it("I am a pending spec");
|
591
|
+
});
|
592
|
+
|
593
|
+
var assertions = function() {
|
594
|
+
expect(pendingSpec.status()).toBe("pending");
|
595
|
+
done();
|
596
|
+
};
|
597
|
+
|
598
|
+
env.addReporter({jasmineDone: assertions});
|
599
|
+
|
600
|
+
env.execute();
|
601
|
+
});
|
602
|
+
|
603
|
+
it("should recover gracefully when there are errors in describe functions", function(done) {
|
604
|
+
var specs = [],
|
605
|
+
reporter = jasmine.createSpyObj(['specDone', 'suiteDone', 'jasmineDone']);
|
606
|
+
|
607
|
+
reporter.specDone.and.callFake(function(result) {
|
608
|
+
specs.push(result.fullName);
|
609
|
+
});
|
610
|
+
|
611
|
+
reporter.jasmineDone.and.callFake(function() {
|
612
|
+
expect(specs).toEqual(['outer1 inner1 should thingy', 'outer1 inner2 should other thingy', 'outer2 should xxx']);
|
613
|
+
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1 inner1', [/inner error/]);
|
614
|
+
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [/outer error/]);
|
615
|
+
done();
|
616
|
+
});
|
617
|
+
|
618
|
+
expect(function() {
|
619
|
+
env.describe("outer1", function() {
|
620
|
+
env.describe("inner1", function() {
|
621
|
+
env.it("should thingy", function() {
|
622
|
+
this.expect(true).toEqual(true);
|
623
|
+
});
|
624
|
+
|
625
|
+
throw new Error("inner error");
|
626
|
+
});
|
627
|
+
|
628
|
+
env.describe("inner2", function() {
|
629
|
+
env.it("should other thingy", function() {
|
630
|
+
this.expect(true).toEqual(true);
|
631
|
+
});
|
632
|
+
});
|
633
|
+
|
634
|
+
throw new Error("outer error");
|
635
|
+
|
636
|
+
});
|
637
|
+
}).not.toThrow();
|
638
|
+
|
639
|
+
env.describe("outer2", function() {
|
640
|
+
env.it("should xxx", function() {
|
641
|
+
this.expect(true).toEqual(true);
|
642
|
+
});
|
643
|
+
});
|
644
|
+
|
645
|
+
env.addReporter(reporter);
|
646
|
+
env.execute();
|
647
|
+
});
|
648
|
+
|
649
|
+
it("re-enters suites that have no *Alls", function(done) {
|
650
|
+
var actions = [],
|
651
|
+
spec1, spec2, spec3;
|
652
|
+
|
653
|
+
env.describe("top", function() {
|
654
|
+
spec1 = env.it("spec1", function() {
|
655
|
+
actions.push("spec1");
|
656
|
+
});
|
657
|
+
|
658
|
+
spec2 = env.it("spec2", function() {
|
659
|
+
actions.push("spec2");
|
660
|
+
});
|
661
|
+
});
|
662
|
+
|
663
|
+
spec3 = env.it("spec3", function() {
|
664
|
+
actions.push("spec3");
|
665
|
+
});
|
666
|
+
|
667
|
+
env.addReporter({
|
668
|
+
jasmineDone: function() {
|
669
|
+
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
|
670
|
+
done();
|
671
|
+
}
|
672
|
+
});
|
673
|
+
|
674
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
675
|
+
});
|
676
|
+
|
677
|
+
it("refuses to re-enter suites with a beforeAll", function() {
|
678
|
+
var actions = [],
|
679
|
+
spec1, spec2, spec3;
|
680
|
+
|
681
|
+
env.describe("top", function() {
|
682
|
+
env.beforeAll(function() {});
|
683
|
+
|
684
|
+
spec1 = env.it("spec1", function() {
|
685
|
+
actions.push("spec1");
|
686
|
+
});
|
687
|
+
|
688
|
+
spec2 = env.it("spec2", function() {
|
689
|
+
actions.push("spec2");
|
690
|
+
});
|
691
|
+
});
|
692
|
+
|
693
|
+
spec3 = env.it("spec3", function() {
|
694
|
+
actions.push("spec3");
|
695
|
+
});
|
696
|
+
|
697
|
+
env.addReporter({
|
698
|
+
jasmineDone: function() {
|
699
|
+
expect(actions).toEqual([]);
|
700
|
+
done();
|
701
|
+
}
|
702
|
+
});
|
703
|
+
|
704
|
+
expect(function() {
|
705
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
706
|
+
}).toThrowError(/beforeAll/);
|
707
|
+
});
|
708
|
+
|
709
|
+
it("refuses to re-enter suites with a afterAll", function() {
|
710
|
+
var actions = [],
|
711
|
+
spec1, spec2, spec3;
|
712
|
+
|
713
|
+
env.describe("top", function() {
|
714
|
+
env.afterAll(function() {});
|
715
|
+
|
716
|
+
spec1 = env.it("spec1", function() {
|
717
|
+
actions.push("spec1");
|
718
|
+
});
|
719
|
+
|
720
|
+
spec2 = env.it("spec2", function() {
|
721
|
+
actions.push("spec2");
|
722
|
+
});
|
723
|
+
});
|
724
|
+
|
725
|
+
spec3 = env.it("spec3", function() {
|
726
|
+
actions.push("spec3");
|
727
|
+
});
|
728
|
+
|
729
|
+
env.addReporter({
|
730
|
+
jasmineDone: function() {
|
731
|
+
expect(actions).toEqual([]);
|
732
|
+
done();
|
733
|
+
}
|
734
|
+
});
|
735
|
+
|
736
|
+
expect(function() {
|
737
|
+
env.execute([spec2.id, spec3.id, spec1.id]);
|
738
|
+
}).toThrowError(/afterAll/);
|
739
|
+
});
|
740
|
+
|
741
|
+
it("should run the tests in a consistent order when a seed is supplied", function(done) {
|
742
|
+
var actions = [];
|
743
|
+
env.seed('123456');
|
744
|
+
env.randomizeTests(true);
|
745
|
+
|
746
|
+
env.beforeEach(function () {
|
747
|
+
actions.push('topSuite beforeEach');
|
748
|
+
});
|
749
|
+
|
750
|
+
env.afterEach(function () {
|
751
|
+
actions.push('topSuite afterEach');
|
752
|
+
});
|
753
|
+
|
754
|
+
env.describe('Something', function() {
|
755
|
+
env.beforeEach(function() {
|
756
|
+
actions.push('outer beforeEach');
|
757
|
+
});
|
758
|
+
|
759
|
+
env.afterEach(function() {
|
760
|
+
actions.push('outer afterEach');
|
761
|
+
});
|
762
|
+
|
763
|
+
env.it('does it 1', function() {
|
764
|
+
actions.push('outer it 1');
|
765
|
+
});
|
766
|
+
|
767
|
+
env.describe('Inner 1', function() {
|
768
|
+
env.beforeEach(function() {
|
769
|
+
actions.push('inner 1 beforeEach');
|
770
|
+
});
|
771
|
+
|
772
|
+
env.afterEach(function() {
|
773
|
+
actions.push('inner 1 afterEach');
|
774
|
+
});
|
775
|
+
|
776
|
+
env.it('does it 2', function() {
|
777
|
+
actions.push('inner 1 it');
|
778
|
+
});
|
779
|
+
});
|
780
|
+
|
781
|
+
env.it('does it 3', function() {
|
782
|
+
actions.push('outer it 2');
|
783
|
+
});
|
784
|
+
|
785
|
+
env.describe('Inner 2', function() {
|
786
|
+
env.beforeEach(function() {
|
787
|
+
actions.push('inner 2 beforeEach');
|
788
|
+
});
|
789
|
+
|
790
|
+
env.afterEach(function() {
|
791
|
+
actions.push('inner 2 afterEach');
|
792
|
+
});
|
793
|
+
|
794
|
+
env.it('does it 2', function() {
|
795
|
+
actions.push('inner 2 it');
|
796
|
+
});
|
797
|
+
});
|
798
|
+
});
|
799
|
+
|
800
|
+
var assertions = function() {
|
801
|
+
var expected = [
|
802
|
+
'topSuite beforeEach',
|
803
|
+
'outer beforeEach',
|
804
|
+
'outer it 2',
|
805
|
+
'outer afterEach',
|
806
|
+
'topSuite afterEach',
|
807
|
+
|
808
|
+
'topSuite beforeEach',
|
809
|
+
'outer beforeEach',
|
810
|
+
'inner 2 beforeEach',
|
811
|
+
'inner 2 it',
|
812
|
+
'inner 2 afterEach',
|
813
|
+
'outer afterEach',
|
814
|
+
'topSuite afterEach',
|
815
|
+
|
816
|
+
'topSuite beforeEach',
|
817
|
+
'outer beforeEach',
|
818
|
+
'inner 1 beforeEach',
|
819
|
+
'inner 1 it',
|
820
|
+
'inner 1 afterEach',
|
821
|
+
'outer afterEach',
|
822
|
+
'topSuite afterEach',
|
823
|
+
|
824
|
+
'topSuite beforeEach',
|
825
|
+
'outer beforeEach',
|
826
|
+
'outer it 1',
|
827
|
+
'outer afterEach',
|
828
|
+
'topSuite afterEach'
|
829
|
+
];
|
830
|
+
expect(actions).toEqual(expected);
|
831
|
+
done();
|
832
|
+
};
|
833
|
+
|
834
|
+
env.addReporter({jasmineDone: assertions});
|
835
|
+
|
836
|
+
env.execute();
|
837
|
+
});
|
838
|
+
|
839
|
+
describe("When throwOnExpectationFailure is set", function() {
|
840
|
+
it("skips to cleanup functions after an error", function(done) {
|
841
|
+
var actions = [];
|
842
|
+
|
843
|
+
env.describe('Something', function() {
|
844
|
+
env.beforeEach(function() {
|
845
|
+
actions.push('outer beforeEach');
|
846
|
+
throw new Error("error");
|
847
|
+
});
|
848
|
+
|
849
|
+
env.afterEach(function() {
|
850
|
+
actions.push('outer afterEach');
|
851
|
+
});
|
852
|
+
|
853
|
+
env.describe('Inner', function() {
|
854
|
+
env.beforeEach(function() {
|
855
|
+
actions.push('inner beforeEach');
|
856
|
+
});
|
857
|
+
|
858
|
+
env.afterEach(function() {
|
859
|
+
actions.push('inner afterEach');
|
860
|
+
});
|
861
|
+
|
862
|
+
env.it('does it' , function() {
|
863
|
+
actions.push('inner it');
|
864
|
+
});
|
865
|
+
});
|
866
|
+
});
|
867
|
+
|
868
|
+
env.throwOnExpectationFailure(true);
|
869
|
+
|
870
|
+
var assertions = function() {
|
871
|
+
expect(actions).toEqual([
|
872
|
+
'outer beforeEach',
|
873
|
+
'inner afterEach',
|
874
|
+
'outer afterEach'
|
875
|
+
]);
|
876
|
+
done();
|
877
|
+
};
|
878
|
+
|
879
|
+
env.addReporter({jasmineDone: assertions});
|
880
|
+
|
881
|
+
env.execute();
|
882
|
+
});
|
883
|
+
|
884
|
+
it("skips to cleanup functions after done.fail is called", function(done) {
|
885
|
+
var actions = [];
|
886
|
+
|
887
|
+
env.describe('Something', function() {
|
888
|
+
env.beforeEach(function(done) {
|
889
|
+
actions.push('beforeEach');
|
890
|
+
done.fail('error');
|
891
|
+
actions.push('after done.fail');
|
892
|
+
});
|
893
|
+
|
894
|
+
env.afterEach(function() {
|
895
|
+
actions.push('afterEach');
|
896
|
+
});
|
897
|
+
|
898
|
+
env.it('does it' , function() {
|
899
|
+
actions.push('it');
|
900
|
+
});
|
901
|
+
});
|
902
|
+
|
903
|
+
env.throwOnExpectationFailure(true);
|
904
|
+
|
905
|
+
var assertions = function() {
|
906
|
+
expect(actions).toEqual([
|
907
|
+
'beforeEach',
|
908
|
+
'afterEach'
|
909
|
+
]);
|
910
|
+
done();
|
911
|
+
};
|
912
|
+
|
913
|
+
env.addReporter({jasmineDone: assertions});
|
914
|
+
|
915
|
+
env.execute();
|
916
|
+
});
|
917
|
+
|
918
|
+
it("skips to cleanup functions when an async function times out", function(done) {
|
919
|
+
var actions = [];
|
920
|
+
|
921
|
+
env.describe('Something', function() {
|
922
|
+
env.beforeEach(function(innerDone) {
|
923
|
+
actions.push('beforeEach');
|
924
|
+
}, 1);
|
925
|
+
|
926
|
+
env.afterEach(function() {
|
927
|
+
actions.push('afterEach');
|
928
|
+
});
|
929
|
+
|
930
|
+
env.it('does it' , function() {
|
931
|
+
actions.push('it');
|
932
|
+
});
|
933
|
+
});
|
934
|
+
|
935
|
+
env.throwOnExpectationFailure(true);
|
936
|
+
|
937
|
+
var assertions = function() {
|
938
|
+
expect(actions).toEqual([
|
939
|
+
'beforeEach',
|
940
|
+
'afterEach'
|
941
|
+
]);
|
942
|
+
done();
|
943
|
+
};
|
944
|
+
|
945
|
+
env.addReporter({jasmineDone: assertions});
|
946
|
+
|
947
|
+
env.execute();
|
948
|
+
});
|
949
|
+
});
|
950
|
+
|
951
|
+
describe("when stopOnSpecFailure is on", function() {
|
952
|
+
it("does not run further specs when one fails", function(done) {
|
953
|
+
var actions = [];
|
954
|
+
|
955
|
+
env.it('fails', function() {
|
956
|
+
actions.push('fails');
|
957
|
+
env.expect(1).toBe(2);
|
958
|
+
});
|
959
|
+
|
960
|
+
env.it('does not run', function() {
|
961
|
+
actions.push('does not run');
|
962
|
+
});
|
963
|
+
|
964
|
+
env.randomizeTests(false);
|
965
|
+
env.stopOnSpecFailure(true);
|
966
|
+
|
967
|
+
var assertions = function() {
|
968
|
+
expect(actions).toEqual(['fails']);
|
969
|
+
done();
|
970
|
+
};
|
971
|
+
|
972
|
+
env.addReporter({ jasmineDone: assertions });
|
973
|
+
env.execute();
|
974
|
+
});
|
975
|
+
});
|
976
|
+
});
|