jasmine-core 2.5.0 → 2.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/console/console.js +1 -1
  3. data/lib/jasmine-core/boot/boot.js +4 -1
  4. data/lib/jasmine-core/boot.js +5 -2
  5. data/lib/jasmine-core/jasmine-html.js +95 -31
  6. data/lib/jasmine-core/jasmine.css +1 -0
  7. data/lib/jasmine-core/jasmine.js +3635 -1684
  8. data/lib/jasmine-core/node_boot.js +1 -1
  9. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +10 -0
  10. data/lib/jasmine-core/spec/core/ClearStackSpec.js +137 -0
  11. data/lib/jasmine-core/spec/core/ClockSpec.js +94 -14
  12. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +26 -8
  13. data/lib/jasmine-core/spec/core/EnvSpec.js +142 -10
  14. data/lib/jasmine-core/spec/core/ExpectationSpec.js +52 -7
  15. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +110 -0
  16. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +132 -4
  17. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +333 -23
  18. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +16 -1
  19. data/lib/jasmine-core/spec/core/SpecSpec.js +30 -8
  20. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +225 -1
  21. data/lib/jasmine-core/spec/core/SpySpec.js +44 -2
  22. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +28 -5
  23. data/lib/jasmine-core/spec/core/SuiteSpec.js +14 -19
  24. data/lib/jasmine-core/spec/core/UserContextSpec.js +54 -0
  25. data/lib/jasmine-core/spec/core/UtilSpec.js +71 -0
  26. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +32 -0
  27. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +32 -0
  28. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +13 -0
  29. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +47 -0
  30. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +13 -0
  31. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +48 -0
  32. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +339 -38
  33. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +156 -3
  34. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
  35. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
  36. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
  37. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +231 -8
  38. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +8 -0
  39. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +42 -0
  40. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
  41. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -0
  42. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +780 -4
  43. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
  44. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +37 -0
  45. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +4 -0
  46. data/lib/jasmine-core/spec/helpers/asyncAwait.js +27 -0
  47. data/lib/jasmine-core/spec/helpers/checkForMap.js +37 -0
  48. data/lib/jasmine-core/spec/helpers/checkForSet.js +41 -0
  49. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
  50. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +20 -0
  51. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +105 -23
  52. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +34 -0
  53. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +1 -1
  54. data/lib/jasmine-core/version.rb +1 -1
  55. metadata +19 -4
@@ -181,6 +181,12 @@ describe("Env integration", function() {
181
181
  }
182
182
  })]
183
183
  }));
184
+ expect(specDone).toHaveBeenCalledWith(jasmine.objectContaining({
185
+ description: 'pretty prints objects',
186
+ failedExpectations: [jasmine.objectContaining({
187
+ message: 'Failed: Object({ prop: \'value\', arr: [ \'works\', true ] })'
188
+ })]
189
+ }));
184
190
  done();
185
191
  }
186
192
  });
@@ -197,6 +203,27 @@ describe("Env integration", function() {
197
203
  env.it('has a message and stack trace from an Error', function() {
198
204
  env.fail(new Error('error message'));
199
205
  });
206
+
207
+ env.it('pretty prints objects', function() {
208
+ env.fail({prop: 'value', arr: ['works', true]});
209
+ })
210
+ });
211
+
212
+ env.execute();
213
+ });
214
+
215
+ it("produces an understandable error message when 'fail' is used outside of a current spec", function(done) {
216
+ var env = new jasmineUnderTest.Env(),
217
+ reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']);
218
+
219
+ reporter.jasmineDone.and.callFake(done);
220
+ env.addReporter(reporter);
221
+
222
+ env.describe("A Suite", function() {
223
+ env.it("an async spec that is actually synchronous", function(underTestCallback) {
224
+ underTestCallback();
225
+ });
226
+ expect(function() { env.fail(); }).toThrowError(/'fail' was used when there was no current spec/);
200
227
  });
201
228
 
202
229
  env.execute();
@@ -216,7 +243,7 @@ describe("Env integration", function() {
216
243
  } else {
217
244
  secondSpecContext = this;
218
245
  }
219
- expect(this).toEqual({});
246
+ expect(this).toEqual(new jasmineUnderTest.UserContext());
220
247
  });
221
248
 
222
249
  env.it("sync spec", function() {
@@ -250,7 +277,7 @@ describe("Env integration", function() {
250
277
 
251
278
  env.beforeEach(function() {
252
279
  specContext = this;
253
- expect(this).toEqual({});
280
+ expect(this).toEqual(new jasmineUnderTest.UserContext());
254
281
  });
255
282
 
256
283
  env.it("sync spec", function(underTestCallback) {
@@ -429,6 +456,41 @@ describe("Env integration", function() {
429
456
  env.execute();
430
457
  });
431
458
 
459
+ it("copes with async failures after done has been called", function(done) {
460
+ var global = {
461
+ setTimeout: function(fn, delay) { setTimeout(fn, delay) },
462
+ clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
463
+ };
464
+ spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
465
+ var env = new jasmineUnderTest.Env(),
466
+ reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone", "suiteDone" ]);
467
+
468
+ reporter.jasmineDone.and.callFake(function() {
469
+ expect(reporter.specDone).not.toHaveFailedExpecationsForRunnable('A suite fails', ['fail thrown']);
470
+ expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('A suite', ['fail thrown']);
471
+ done();
472
+ });
473
+
474
+ env.addReporter(reporter);
475
+
476
+ env.fdescribe('A suite', function() {
477
+ env.it('fails', function(specDone) {
478
+ setTimeout(function() {
479
+ specDone();
480
+ setTimeout(function() {
481
+ global.onerror('fail');
482
+ });
483
+ });
484
+ });
485
+ });
486
+
487
+ env.describe('Ignored', function() {
488
+ env.it('is not run', function() {});
489
+ });
490
+
491
+ env.execute();
492
+ });
493
+
432
494
  describe('suiteDone reporting', function(){
433
495
  it("reports when an afterAll fails an expectation", function(done) {
434
496
  var env = new jasmineUnderTest.Env(),
@@ -724,7 +786,7 @@ describe("Env integration", function() {
724
786
  env.execute();
725
787
  });
726
788
 
727
- it('can be configured to allow respying on functions', function () {
789
+ it('can be configured to allow respying on functions', function (done) {
728
790
  var env = new jasmineUnderTest.Env(),
729
791
  foo = {
730
792
  bar: function () {
@@ -733,6 +795,7 @@ describe("Env integration", function() {
733
795
  };
734
796
 
735
797
  env.allowRespy(true);
798
+ env.addReporter({ jasmineDone: done });
736
799
 
737
800
  env.describe('test suite', function(){
738
801
  env.it('spec 0', function(){
@@ -866,7 +929,14 @@ describe("Env integration", function() {
866
929
  });
867
930
 
868
931
  it("should run async specs in order, waiting for them to complete", function(done) {
869
- var env = new jasmineUnderTest.Env(), mutatedVar;
932
+ var env = new jasmineUnderTest.Env(),
933
+ reporter = jasmine.createSpyObj('reporter', ['jasmineDone']),
934
+ mutatedVar;
935
+
936
+ reporter.jasmineDone.and.callFake(function() {
937
+ done();
938
+ });
939
+ env.addReporter(reporter);
870
940
 
871
941
  env.describe("tests", function() {
872
942
  env.beforeEach(function() {
@@ -877,7 +947,6 @@ describe("Env integration", function() {
877
947
  setTimeout(function() {
878
948
  expect(mutatedVar).toEqual(2);
879
949
  underTestCallback();
880
- done();
881
950
  }, 0);
882
951
  });
883
952
 
@@ -890,16 +959,15 @@ describe("Env integration", function() {
890
959
  });
891
960
 
892
961
  describe("with a mock clock", function() {
893
- var originalTimeout;
894
-
895
962
  beforeEach(function() {
896
- originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
963
+ this.originalTimeout = jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL;
964
+ this.realSetTimeout = setTimeout;
897
965
  jasmine.clock().install();
898
966
  });
899
967
 
900
968
  afterEach(function() {
901
969
  jasmine.clock().uninstall();
902
- jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
970
+ jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = this.originalTimeout;
903
971
  });
904
972
 
905
973
  it("should wait a specified interval before failing specs haven't called done yet", function(done) {
@@ -940,8 +1008,8 @@ describe("Env integration", function() {
940
1008
  env.addReporter(reporter);
941
1009
  jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 1290;
942
1010
 
943
- env.beforeAll(function(done) {
944
- jasmine.clock().tick(1290);
1011
+ env.beforeAll(function(innerDone) {
1012
+ jasmine.clock().tick(1291);
945
1013
  });
946
1014
 
947
1015
  env.it("spec that will be failed", function() {
@@ -955,7 +1023,7 @@ describe("Env integration", function() {
955
1023
  env.execute();
956
1024
  });
957
1025
 
958
- it("should not use the mock clock for asynchronous timeouts", function(){
1026
+ it("should not use the mock clock for asynchronous timeouts", function(done){
959
1027
  var env = new jasmineUnderTest.Env(),
960
1028
  reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]),
961
1029
  clock = env.clock;
@@ -963,6 +1031,7 @@ describe("Env integration", function() {
963
1031
  reporter.jasmineDone.and.callFake(function() {
964
1032
  expect(reporter.specDone.calls.count()).toEqual(1);
965
1033
  expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(jasmine.objectContaining({status: 'passed'}));
1034
+ done();
966
1035
  });
967
1036
 
968
1037
  env.addReporter(reporter);
@@ -976,10 +1045,11 @@ describe("Env integration", function() {
976
1045
  clock.uninstall();
977
1046
  });
978
1047
 
979
- env.it("spec that should not time out", function(done) {
1048
+ env.it("spec that should not time out", function(innerDone) {
980
1049
  clock.tick(6);
981
1050
  expect(true).toEqual(true);
982
- done();
1051
+ innerDone();
1052
+ jasmine.clock().tick(1);
983
1053
  });
984
1054
 
985
1055
  env.execute();
@@ -1010,11 +1080,13 @@ describe("Env integration", function() {
1010
1080
  });
1011
1081
 
1012
1082
  env.execute();
1083
+ jasmine.clock().tick(1);
1013
1084
  });
1014
1085
 
1015
1086
  it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
1016
1087
  var env = new jasmineUnderTest.Env(),
1017
- reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
1088
+ reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']),
1089
+ realSetTimeout = this.realSetTimeout;
1018
1090
 
1019
1091
  reporter.jasmineDone.and.callFake(function() {
1020
1092
  expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite beforeAll times out', [
@@ -1044,10 +1116,19 @@ describe("Env integration", function() {
1044
1116
  jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 10000;
1045
1117
 
1046
1118
  env.describe('suite', function() {
1119
+ env.afterAll(function() {
1120
+ if (jasmine.getEnv().ieVersion < 9) {
1121
+ } else {
1122
+ realSetTimeout(function() {
1123
+ jasmine.clock().tick(10);
1124
+ }, 100);
1125
+ }
1126
+ });
1047
1127
  env.describe('beforeAll', function() {
1048
1128
  env.beforeAll(function(innerDone) {
1049
- jasmine.clock().tick(5001);
1050
- innerDone();
1129
+ realSetTimeout(function() {
1130
+ jasmine.clock().tick(5001);
1131
+ }, 0);
1051
1132
  }, 5000);
1052
1133
 
1053
1134
  env.it('times out', function() {});
@@ -1055,8 +1136,9 @@ describe("Env integration", function() {
1055
1136
 
1056
1137
  env.describe('afterAll', function() {
1057
1138
  env.afterAll(function(innerDone) {
1058
- jasmine.clock().tick(2001);
1059
- innerDone();
1139
+ realSetTimeout(function() {
1140
+ jasmine.clock().tick(2001);
1141
+ }, 0);
1060
1142
  }, 2000);
1061
1143
 
1062
1144
  env.it('times out', function() {});
@@ -1064,8 +1146,9 @@ describe("Env integration", function() {
1064
1146
 
1065
1147
  env.describe('beforeEach', function() {
1066
1148
  env.beforeEach(function(innerDone) {
1067
- jasmine.clock().tick(1001);
1068
- innerDone();
1149
+ realSetTimeout(function() {
1150
+ jasmine.clock().tick(1001);
1151
+ }, 0);
1069
1152
  }, 1000);
1070
1153
 
1071
1154
  env.it('times out', function() {});
@@ -1073,16 +1156,18 @@ describe("Env integration", function() {
1073
1156
 
1074
1157
  env.describe('afterEach', function() {
1075
1158
  env.afterEach(function(innerDone) {
1076
- jasmine.clock().tick(4001);
1077
- innerDone();
1159
+ realSetTimeout(function() {
1160
+ jasmine.clock().tick(4001);
1161
+ }, 0);
1078
1162
  }, 4000);
1079
1163
 
1080
1164
  env.it('times out', function() {});
1081
1165
  });
1082
1166
 
1083
1167
  env.it('it times out', function(innerDone) {
1084
- jasmine.clock().tick(6001);
1085
- innerDone();
1168
+ realSetTimeout(function() {
1169
+ jasmine.clock().tick(6001);
1170
+ }, 0);
1086
1171
  }, 6000);
1087
1172
  });
1088
1173
 
@@ -1130,6 +1215,8 @@ describe("Env integration", function() {
1130
1215
  env.fail();
1131
1216
  innerDone();
1132
1217
  }, 1);
1218
+ jasmine.clock().tick(1);
1219
+ jasmine.clock().tick(1);
1133
1220
  });
1134
1221
 
1135
1222
  env.it('specifies a message', function(innerDone) {
@@ -1137,12 +1224,16 @@ describe("Env integration", function() {
1137
1224
  env.fail('messy message');
1138
1225
  innerDone();
1139
1226
  }, 1);
1227
+ jasmine.clock().tick(1);
1228
+ jasmine.clock().tick(1);
1140
1229
  });
1141
1230
 
1142
1231
  env.it('fails via the done callback', function(innerDone) {
1143
1232
  setTimeout(function() {
1144
1233
  innerDone.fail('done failed');
1145
1234
  }, 1);
1235
+ jasmine.clock().tick(1);
1236
+ jasmine.clock().tick(1);
1146
1237
  });
1147
1238
 
1148
1239
  env.it('has a message from an Error', function(innerDone) {
@@ -1150,14 +1241,12 @@ describe("Env integration", function() {
1150
1241
  env.fail(new Error('error message'));
1151
1242
  innerDone();
1152
1243
  }, 1);
1244
+ jasmine.clock().tick(1);
1245
+ jasmine.clock().tick(1);
1153
1246
  });
1154
1247
  });
1155
1248
 
1156
1249
  env.execute();
1157
- jasmine.clock().tick(1);
1158
- jasmine.clock().tick(1);
1159
- jasmine.clock().tick(1);
1160
- jasmine.clock().tick(1);
1161
1250
  });
1162
1251
  });
1163
1252
 
@@ -1186,7 +1275,7 @@ describe("Env integration", function() {
1186
1275
  env.execute();
1187
1276
  });
1188
1277
 
1189
- it('should only run focused suites', function(){
1278
+ it('should only run focused suites', function(done){
1190
1279
  var env = new jasmineUnderTest.Env(),
1191
1280
  calls = [];
1192
1281
 
@@ -1225,7 +1314,8 @@ describe("Env integration", function() {
1225
1314
 
1226
1315
  reporter.jasmineDone.and.callFake(function() {
1227
1316
  expect(reporter.jasmineStarted).toHaveBeenCalledWith({
1228
- totalSpecsDefined: 1
1317
+ totalSpecsDefined: 1,
1318
+ order: jasmine.any(jasmineUnderTest.Order)
1229
1319
  });
1230
1320
 
1231
1321
  expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
@@ -1260,7 +1350,8 @@ describe("Env integration", function() {
1260
1350
 
1261
1351
  reporter.jasmineDone.and.callFake(function() {
1262
1352
  expect(reporter.jasmineStarted).toHaveBeenCalledWith({
1263
- totalSpecsDefined: 1
1353
+ totalSpecsDefined: 1,
1354
+ order: jasmine.any(jasmineUnderTest.Order)
1264
1355
  });
1265
1356
 
1266
1357
  expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
@@ -1298,7 +1389,8 @@ describe("Env integration", function() {
1298
1389
 
1299
1390
  reporter.jasmineDone.and.callFake(function() {
1300
1391
  expect(reporter.jasmineStarted).toHaveBeenCalledWith({
1301
- totalSpecsDefined: 5
1392
+ totalSpecsDefined: 5,
1393
+ order: jasmine.any(jasmineUnderTest.Order)
1302
1394
  });
1303
1395
 
1304
1396
  expect(reporter.specDone.calls.count()).toBe(5);
@@ -1355,6 +1447,34 @@ describe("Env integration", function() {
1355
1447
  env.execute();
1356
1448
  });
1357
1449
 
1450
+ it("should report the random seed at the beginning and end of execution", function(done) {
1451
+ var env = new jasmineUnderTest.Env(),
1452
+ reporter = jasmine.createSpyObj('fakeReporter', [
1453
+ "jasmineStarted",
1454
+ "jasmineDone",
1455
+ "suiteStarted",
1456
+ "suiteDone",
1457
+ "specStarted",
1458
+ "specDone"
1459
+ ]);
1460
+ env.randomizeTests(true);
1461
+ env.seed('123456');
1462
+
1463
+ reporter.jasmineDone.and.callFake(function(doneArg) {
1464
+ expect(reporter.jasmineStarted).toHaveBeenCalled();
1465
+ var startedArg = reporter.jasmineStarted.calls.argsFor(0)[0];
1466
+ expect(startedArg.order.random).toEqual(true);
1467
+ expect(startedArg.order.seed).toEqual('123456');
1468
+
1469
+ expect(doneArg.order.random).toEqual(true);
1470
+ expect(doneArg.order.seed).toEqual('123456');
1471
+ done();
1472
+ });
1473
+
1474
+ env.addReporter(reporter);
1475
+ env.execute();
1476
+ });
1477
+
1358
1478
  it('should report pending spec messages', function(done) {
1359
1479
  var env = new jasmineUnderTest.Env(),
1360
1480
  reporter = jasmine.createSpyObj('fakeReporter', [
@@ -1365,6 +1485,7 @@ describe("Env integration", function() {
1365
1485
  reporter.jasmineDone.and.callFake(function() {
1366
1486
  var specStatus = reporter.specDone.calls.argsFor(0)[0];
1367
1487
 
1488
+ expect(specStatus.status).toBe('pending');
1368
1489
  expect(specStatus.pendingReason).toBe('with a message');
1369
1490
 
1370
1491
  done();
@@ -1379,6 +1500,45 @@ describe("Env integration", function() {
1379
1500
  env.execute();
1380
1501
  });
1381
1502
 
1503
+ it('should report pending spec messages from promise-returning functions', function(done) {
1504
+ function StubPromise(fn) {
1505
+ try {
1506
+ fn();
1507
+ } catch (e) {
1508
+ this.exception = e;
1509
+ }
1510
+ }
1511
+
1512
+ StubPromise.prototype.then = function(resolve, reject) {
1513
+ reject(this.exception);
1514
+ };
1515
+
1516
+ var env = new jasmineUnderTest.Env(),
1517
+ reporter = jasmine.createSpyObj('fakeReporter', [
1518
+ 'specDone',
1519
+ 'jasmineDone'
1520
+ ]);
1521
+
1522
+ reporter.jasmineDone.and.callFake(function() {
1523
+ var specStatus = reporter.specDone.calls.argsFor(0)[0];
1524
+
1525
+ expect(specStatus.status).toBe('pending');
1526
+ expect(specStatus.pendingReason).toBe('with a message');
1527
+
1528
+ done();
1529
+ });
1530
+
1531
+ env.addReporter(reporter);
1532
+
1533
+ env.it('will be pending', function() {
1534
+ return new StubPromise(function() {
1535
+ env.pending('with a message');
1536
+ });
1537
+ });
1538
+
1539
+ env.execute();
1540
+ });
1541
+
1382
1542
  it('should report using fallback reporter', function(done) {
1383
1543
  var env = new jasmineUnderTest.Env(),
1384
1544
  reporter = jasmine.createSpyObj('fakeReporter', [
@@ -1414,10 +1574,11 @@ describe("Env integration", function() {
1414
1574
 
1415
1575
  reporter.jasmineDone.and.callFake(function() {
1416
1576
  expect(reporter.jasmineStarted).toHaveBeenCalledWith({
1417
- totalSpecsDefined: 1
1577
+ totalSpecsDefined: 1,
1578
+ order: jasmine.any(jasmineUnderTest.Order)
1418
1579
  });
1419
1580
 
1420
- expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'pending' }));
1581
+ expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ status: 'disabled' }));
1421
1582
  expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ description: 'xd out', status: 'pending' }));
1422
1583
  expect(reporter.suiteDone.calls.count()).toBe(4);
1423
1584
 
@@ -1572,14 +1733,17 @@ describe("Env integration", function() {
1572
1733
  });
1573
1734
 
1574
1735
  it("produces an understandable error message when an 'expect' is used outside of a current spec", function(done) {
1575
- var env = new jasmineUnderTest.Env();
1736
+ var env = new jasmineUnderTest.Env(),
1737
+ reporter = jasmine.createSpyObj('fakeReporter', ['jasmineDone']);
1738
+
1739
+ reporter.jasmineDone.and.callFake(done);
1740
+ env.addReporter(reporter);
1576
1741
 
1577
1742
  env.describe("A Suite", function() {
1578
1743
  env.it("an async spec that is actually synchronous", function(underTestCallback) {
1579
1744
  underTestCallback();
1580
- expect(function() { env.expect('a').toEqual('a'); }).toThrowError(/'expect' was used when there was no current spec/);
1581
- done();
1582
1745
  });
1746
+ expect(function() { env.expect('a').toEqual('a'); }).toThrowError(/'expect' was used when there was no current spec/);
1583
1747
  });
1584
1748
 
1585
1749
  env.execute();
@@ -1746,4 +1910,141 @@ describe("Env integration", function() {
1746
1910
 
1747
1911
  env.execute();
1748
1912
  });
1913
+
1914
+ it("should associate errors thrown from async code with the correct runnable", function(done) {
1915
+ var env = new jasmineUnderTest.Env(),
1916
+ reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone','specDone']);
1917
+
1918
+ reporter.jasmineDone.and.callFake(function() {
1919
+ expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('async suite', [
1920
+ /^(((Uncaught )?Error: suite( thrown)?)|(suite thrown))$/
1921
+ ]);
1922
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite async spec', [
1923
+ /^(((Uncaught )?Error: spec( thrown)?)|(spec thrown))$/
1924
+ ]);
1925
+ done();
1926
+ });
1927
+
1928
+ env.addReporter(reporter);
1929
+
1930
+ env.describe('async suite', function() {
1931
+ env.afterAll(function(innerDone) {
1932
+ setTimeout(function() { throw new Error('suite'); }, 1);
1933
+ }, 10);
1934
+
1935
+ env.it('spec', function() {});
1936
+ });
1937
+
1938
+ env.describe('suite', function() {
1939
+ env.it('async spec', function(innerDone) {
1940
+ setTimeout(function() { throw new Error('spec'); }, 1);
1941
+ }, 10);
1942
+ });
1943
+
1944
+ env.execute();
1945
+ });
1946
+
1947
+ it('should throw on suites/specs/befores/afters nested in methods other than \'describe\'', function(done) {
1948
+ var env = new jasmineUnderTest.Env(),
1949
+ reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
1950
+
1951
+ reporter.jasmineDone.and.callFake(function() {
1952
+ var msg = /\'.*\' should only be used in \'describe\' function/;
1953
+
1954
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite describe', [msg]);
1955
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite xdescribe', [msg]);
1956
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('suite fdescribe', [msg]);
1957
+
1958
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec it', [msg]);
1959
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec xit', [msg]);
1960
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('spec fit', [msg]);
1961
+
1962
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('beforeAll spec', [msg]);
1963
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('beforeEach spec', [msg]);
1964
+
1965
+ expect(reporter.suiteDone).toHaveFailedExpecationsForRunnable('afterAll', [msg]);
1966
+ expect(reporter.specDone).toHaveFailedExpecationsForRunnable('afterEach spec', [msg]);
1967
+
1968
+ done();
1969
+ });
1970
+
1971
+ env.addReporter(reporter);
1972
+
1973
+ env.describe('suite', function() {
1974
+ env.it('describe', function() { env.describe('inner suite', function() {}); });
1975
+ env.it('xdescribe', function() { env.xdescribe('inner suite', function() {}); });
1976
+ env.it('fdescribe', function() { env.fdescribe('inner suite', function() {}); });
1977
+ });
1978
+
1979
+ env.describe('spec', function() {
1980
+ env.it('it', function() { env.it('inner spec', function() {}); });
1981
+ env.it('xit', function() { env.xit('inner spec', function() {}); });
1982
+ env.it('fit', function() { env.fit('inner spec', function() {}); });
1983
+ });
1984
+
1985
+ env.describe('beforeAll', function() {
1986
+ env.beforeAll(function() { env.beforeAll(function() {}); });
1987
+ env.it('spec', function() {});
1988
+ });
1989
+
1990
+ env.describe('beforeEach', function() {
1991
+ env.beforeEach(function() { env.beforeEach(function() {}); });
1992
+ env.it('spec', function() {});
1993
+ });
1994
+
1995
+ env.describe('afterAll', function() {
1996
+ env.afterAll(function() { env.afterAll(function() {}); });
1997
+ env.it('spec', function() {});
1998
+ });
1999
+
2000
+ env.describe('afterEach', function() {
2001
+ env.afterEach(function() { env.afterEach(function() {}); });
2002
+ env.it('spec', function() {});
2003
+ });
2004
+
2005
+ env.execute();
2006
+ });
2007
+
2008
+ it('should report deprecation warnings on the correct specs and suites', function(done) {
2009
+ var env = new jasmineUnderTest.Env(),
2010
+ reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
2011
+
2012
+ reporter.jasmineDone.and.callFake(function(result) {
2013
+ expect(result.deprecationWarnings).toEqual([
2014
+ jasmine.objectContaining({ message: 'top level deprecation' })
2015
+ ]);
2016
+
2017
+ expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({
2018
+ fullName: 'suite',
2019
+ deprecationWarnings: [
2020
+ jasmine.objectContaining({ message: 'suite level deprecation' })
2021
+ ]
2022
+ }));
2023
+
2024
+ expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({
2025
+ fullName: 'suite spec',
2026
+ deprecationWarnings: [
2027
+ jasmine.objectContaining({ message: 'spec level deprecation' })
2028
+ ]
2029
+ }));
2030
+
2031
+ done();
2032
+ });
2033
+
2034
+ env.addReporter(reporter);
2035
+
2036
+ env.deprecated('top level deprecation');
2037
+
2038
+ env.describe('suite', function() {
2039
+ env.beforeAll(function() {
2040
+ env.deprecated('suite level deprecation');
2041
+ });
2042
+
2043
+ env.it('spec', function() {
2044
+ env.deprecated('spec level deprecation');
2045
+ });
2046
+ });
2047
+
2048
+ env.execute();
2049
+ });
1749
2050
  });