How to use afterEach method in root

Best JavaScript code snippet using root

SpecRunningSpec.js

Source:SpecRunningSpec.js Github

copy

Full Screen

...66 var actions = [];67 env.beforeEach(function () {68 actions.push('topSuite beforeEach');69 });70 env.afterEach(function () {71 actions.push('topSuite afterEach');72 });73 env.describe('Something', function() {74 env.beforeEach(function() {75 actions.push('outer beforeEach');76 });77 env.afterEach(function() {78 actions.push('outer afterEach');79 });80 env.it('does it 1', function() {81 actions.push('outer it 1');82 });83 env.describe('Inner 1', function() {84 env.beforeEach(function() {85 actions.push('inner 1 beforeEach');86 });87 env.afterEach(function() {88 actions.push('inner 1 afterEach');89 });90 env.it('does it 2', function() {91 actions.push('inner 1 it');92 });93 });94 env.it('does it 3', function() {95 actions.push('outer it 2');96 });97 env.describe('Inner 2', function() {98 env.beforeEach(function() {99 actions.push('inner 2 beforeEach');100 });101 env.afterEach(function() {102 actions.push('inner 2 afterEach');103 });104 env.it('does it 2', function() {105 actions.push('inner 2 it');106 });107 });108 });109 var assertions = function() {110 var expected = [111 "topSuite beforeEach",112 "outer beforeEach",113 "outer it 1",114 "outer afterEach",115 "topSuite afterEach",116 "topSuite beforeEach",117 "outer beforeEach",118 "inner 1 beforeEach",119 "inner 1 it",120 "inner 1 afterEach",121 "outer afterEach",122 "topSuite afterEach",123 "topSuite beforeEach",124 "outer beforeEach",125 "outer it 2",126 "outer afterEach",127 "topSuite afterEach",128 "topSuite beforeEach",129 "outer beforeEach",130 "inner 2 beforeEach",131 "inner 2 it",132 "inner 2 afterEach",133 "outer afterEach",134 "topSuite afterEach"135 ];136 expect(actions).toEqual(expected);137 done();138 };139 env.addReporter({jasmineDone: assertions});140 env.execute();141 });142 it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {143 var actions = [];144 env.beforeEach(function () {145 actions.push('runner beforeEach1');146 });147 env.afterEach(function () {148 actions.push('runner afterEach1');149 });150 env.beforeEach(function () {151 actions.push('runner beforeEach2');152 });153 env.afterEach(function () {154 actions.push('runner afterEach2');155 });156 env.describe('Something', function() {157 env.beforeEach(function() {158 actions.push('beforeEach1');159 });160 env.afterEach(function() {161 actions.push('afterEach1');162 });163 env.beforeEach(function() {164 actions.push('beforeEach2');165 });166 env.afterEach(function() {167 actions.push('afterEach2');168 });169 env.it('does it 1', function() {170 actions.push('outer it 1');171 });172 });173 var assertions = function() {174 var expected = [175 "runner beforeEach1",176 "runner beforeEach2",177 "beforeEach1",178 "beforeEach2",179 "outer it 1",180 "afterEach2",181 "afterEach1",182 "runner afterEach2",183 "runner afterEach1"184 ];185 expect(actions).toEqual(expected);186 done();187 };188 env.addReporter({jasmineDone: assertions});189 env.execute();190 });191 it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {192 var actions = [];193 env.beforeAll(function() {194 actions.push('runner beforeAll');195 });196 env.afterAll(function() {197 actions.push('runner afterAll');198 });199 env.beforeEach(function () {200 actions.push('runner beforeEach');201 });202 env.afterEach(function () {203 actions.push('runner afterEach');204 });205 env.describe('Something', function() {206 env.beforeEach(function() {207 actions.push('inner beforeEach');208 });209 env.afterEach(function() {210 actions.push('inner afterEach');211 });212 env.beforeAll(function() {213 actions.push('inner beforeAll');214 });215 env.afterAll(function() {216 actions.push('inner afterAll');217 });218 env.it('does something or other', function() {219 actions.push('it');220 });221 });222 var assertions = function() {223 var expected = [224 "runner beforeAll",225 "inner beforeAll",226 "runner beforeEach",227 "inner beforeEach",228 "it",229 "inner afterEach",230 "runner afterEach",231 "inner afterAll",232 "runner afterAll"233 ];234 expect(actions).toEqual(expected);235 done();236 };237 env.addReporter({jasmineDone: assertions});238 env.execute();239 });240 it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {241 var actions = [],242 spec,243 spec2;244 env.beforeAll(function() {245 actions.push('runner beforeAll');246 });247 env.afterAll(function() {248 actions.push('runner afterAll');249 });250 env.beforeEach(function () {251 actions.push('runner beforeEach');252 });253 env.afterEach(function () {254 actions.push('runner afterEach');255 });256 env.describe('Something', function() {257 env.beforeEach(function() {258 actions.push('inner beforeEach');259 });260 env.afterEach(function() {261 actions.push('inner afterEach');262 });263 env.beforeAll(function() {264 actions.push('inner beforeAll');265 });266 env.afterAll(function() {267 actions.push('inner afterAll');268 });269 spec = env.it('does something', function() {270 actions.push('it');271 });272 spec2 = env.it('does something or other', function() {273 actions.push('it2');274 });275 });276 var assertions = function() {277 var expected = [278 "runner beforeAll",279 "inner beforeAll",280 "runner beforeEach",281 "inner beforeEach",282 "it2",283 "inner afterEach",284 "runner afterEach",285 "runner beforeEach",286 "inner beforeEach",287 "it",288 "inner afterEach",289 "runner afterEach",290 "inner afterAll",291 "runner afterAll"292 ];293 expect(actions).toEqual(expected);294 done();295 };296 env.addReporter({jasmineDone: assertions});297 env.execute([spec2.id, spec.id]);298 });299 it('only runs *Alls once in a focused suite', function(done){300 var actions = [];301 env.fdescribe('Suite', function() {302 env.beforeAll(function(){303 actions.push('beforeAll');304 });305 env.it('should run beforeAll once', function() {306 actions.push('spec');307 });308 env.afterAll(function(){309 actions.push('afterAll');310 });311 });312 var assertions = function() {313 expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);314 done();315 };316 env.addReporter({jasmineDone: assertions});317 env.execute();318 });319 describe('focused runnables', function() {320 it('runs the relevant alls and eachs for each runnable', function(done) {321 var actions = [];322 env.beforeAll(function() {actions.push('beforeAll')});323 env.afterAll(function() {actions.push('afterAll')});324 env.beforeEach(function() {actions.push('beforeEach')});325 env.afterEach(function() {actions.push('afterEach')});326 env.fdescribe('a focused suite', function() {327 env.it('is run', function() {328 actions.push('spec in fdescribe')329 });330 });331 env.describe('an unfocused suite', function() {332 env.fit('has a focused spec', function() {333 actions.push('focused spec')334 });335 });336 var assertions = function() {337 var expected = [338 'beforeAll',339 'beforeEach',340 'spec in fdescribe',341 'afterEach',342 'beforeEach',343 'focused spec',344 'afterEach',345 'afterAll'346 ];347 expect(actions).toEqual(expected);348 done();349 };350 env.addReporter({jasmineDone: assertions});351 env.execute();352 });353 it('focused specs in focused suites cause non-focused siblings to not run', function(done){354 var actions = [];355 env.fdescribe('focused suite', function() {356 env.it('unfocused spec', function() {357 actions.push('unfocused spec')358 });359 env.fit('focused spec', function() {360 actions.push('focused spec')361 });362 });363 var assertions = function() {364 var expected = ['focused spec'];365 expect(actions).toEqual(expected);366 done();367 };368 env.addReporter({jasmineDone: assertions});369 env.execute();370 });371 it('focused suites in focused suites cause non-focused siblings to not run', function(done){372 var actions = [];373 env.fdescribe('focused suite', function() {374 env.it('unfocused spec', function() {375 actions.push('unfocused spec')376 });377 env.fdescribe('inner focused suite', function() {378 env.it('inner spec', function() {379 actions.push('inner spec');380 });381 });382 });383 var assertions = function() {384 var expected = ['inner spec'];385 expect(actions).toEqual(expected);386 done();387 };388 env.addReporter({jasmineDone: assertions});389 env.execute();390 });391 it('focused runnables unfocus ancestor focused suites', function() {392 var actions = [];393 env.fdescribe('focused suite', function() {394 env.it('unfocused spec', function() {395 actions.push('unfocused spec')396 });397 env.describe('inner focused suite', function() {398 env.fit('focused spec', function() {399 actions.push('focused spec');400 });401 });402 });403 var assertions = function() {404 var expected = ['focused spec'];405 expect(actions).toEqual(expected);406 done();407 };408 env.addReporter({jasmineDone: assertions});409 env.execute();410 });411 });412 it("shouldn't run disabled suites", function(done) {413 var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),414 suite = env.describe('A Suite', function() {415 env.xdescribe('with a disabled suite', function(){416 env.it('spec inside a disabled suite', specInADisabledSuite);417 });418 });419 var assertions = function() {420 expect(specInADisabledSuite).not.toHaveBeenCalled();421 done();422 };423 env.addReporter({jasmineDone: assertions});424 env.execute();425 });426 it("should allow top level suites to be disabled", function() {427 var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),428 otherSpec = jasmine.createSpy("otherSpec");429 env.xdescribe('A disabled suite', function() {430 env.it('spec inside a disabled suite', specInADisabledSuite);431 });432 env.describe('Another suite', function() {433 env.it('another spec', otherSpec);434 });435 var assertions = function() {436 expect(specInADisabledSuite).not.toHaveBeenCalled();437 expect(otherSpec).toHaveBeenCalled();438 done();439 };440 env.addReporter({jasmineDone: assertions});441 env.execute();442 });443 it("should set all pending specs to pending when a suite is run", function(done) {444 var pendingSpec,445 suite = env.describe('default current suite', function() {446 pendingSpec = env.it("I am a pending spec");447 });448 var assertions = function() {449 expect(pendingSpec.status()).toBe("pending");450 done();451 };452 env.addReporter({jasmineDone: assertions});453 env.execute();454 });455 it("should recover gracefully when there are errors in describe functions", function(done) {456 var specs = [],457 reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);458 reporter.specDone.and.callFake(function(result) {459 specs.push(result.fullName);460 });461 reporter.jasmineDone.and.callFake(function() {462 expect(specs).toContain('outer1 inner1 should thingy');463 expect(specs).toContain('outer1 inner1 encountered a declaration exception');464 expect(specs).toContain('outer1 inner2 should other thingy');465 expect(specs).toContain('outer1 encountered a declaration exception');466 expect(specs).toContain('outer2 should xxx');467 done();468 });469 expect(function() {470 env.describe("outer1", function() {471 env.describe("inner1", function() {472 env.it("should thingy", function() {473 this.expect(true).toEqual(true);474 });475 throw new Error("fake error");476 });477 env.describe("inner2", function() {478 env.it("should other thingy", function() {479 this.expect(true).toEqual(true);480 });481 });482 throw new Error("fake error");483 });484 }).not.toThrow();485 env.describe("outer2", function() {486 env.it("should xxx", function() {487 this.expect(true).toEqual(true);488 });489 });490 env.addReporter(reporter);491 env.execute();492 });493 it("re-enters suites that have no *Alls", function(done) {494 var actions = [],495 spec1, spec2, spec3;496 env.describe("top", function() {497 spec1 = env.it("spec1", function() {498 actions.push("spec1");499 });500 spec2 = env.it("spec2", function() {501 actions.push("spec2");502 });503 });504 spec3 = env.it("spec3", function() {505 actions.push("spec3");506 });507 env.addReporter({508 jasmineDone: function() {509 expect(actions).toEqual(["spec2", "spec3", "spec1"]);510 done();511 }512 });513 env.execute([spec2.id, spec3.id, spec1.id]);514 });515 it("refuses to re-enter suites with a beforeAll", function() {516 var actions = [],517 spec1, spec2, spec3;518 env.describe("top", function() {519 env.beforeAll(function() {});520 spec1 = env.it("spec1", function() {521 actions.push("spec1");522 });523 spec2 = env.it("spec2", function() {524 actions.push("spec2");525 });526 });527 spec3 = env.it("spec3", function() {528 actions.push("spec3");529 });530 env.addReporter({531 jasmineDone: function() {532 expect(actions).toEqual([]);533 done();534 }535 });536 expect(function() {537 env.execute([spec2.id, spec3.id, spec1.id]);538 }).toThrowError(/beforeAll/);539 });540 it("refuses to re-enter suites with a afterAll", function() {541 var actions = [],542 spec1, spec2, spec3;543 env.describe("top", function() {544 env.afterAll(function() {});545 spec1 = env.it("spec1", function() {546 actions.push("spec1");547 });548 spec2 = env.it("spec2", function() {549 actions.push("spec2");550 });551 });552 spec3 = env.it("spec3", function() {553 actions.push("spec3");554 });555 env.addReporter({556 jasmineDone: function() {557 expect(actions).toEqual([]);558 done();559 }560 });561 expect(function() {562 env.execute([spec2.id, spec3.id, spec1.id]);563 }).toThrowError(/afterAll/);564 });565 it("should run the tests in a consistent order when a seed is supplied", function(done) {566 var actions = [];567 env.randomizeTests(true);568 env.seed('123456');569 env.beforeEach(function () {570 actions.push('topSuite beforeEach');571 });572 env.afterEach(function () {573 actions.push('topSuite afterEach');574 });575 env.describe('Something', function() {576 env.beforeEach(function() {577 actions.push('outer beforeEach');578 });579 env.afterEach(function() {580 actions.push('outer afterEach');581 });582 env.it('does it 1', function() {583 actions.push('outer it 1');584 });585 env.describe('Inner 1', function() {586 env.beforeEach(function() {587 actions.push('inner 1 beforeEach');588 });589 env.afterEach(function() {590 actions.push('inner 1 afterEach');591 });592 env.it('does it 2', function() {593 actions.push('inner 1 it');594 });595 });596 env.it('does it 3', function() {597 actions.push('outer it 2');598 });599 env.describe('Inner 2', function() {600 env.beforeEach(function() {601 actions.push('inner 2 beforeEach');602 });603 env.afterEach(function() {604 actions.push('inner 2 afterEach');605 });606 env.it('does it 2', function() {607 actions.push('inner 2 it');608 });609 });610 });611 var assertions = function() {612 var expected = [613 'topSuite beforeEach',614 'outer beforeEach',615 'outer it 2',616 'outer afterEach',617 'topSuite afterEach',...

Full Screen

Full Screen

SpecRunningSpec-836403183fdd79d7c6a85caa1875c36cf801d68feef3dc6f791569016414af22.js

Source:SpecRunningSpec-836403183fdd79d7c6a85caa1875c36cf801d68feef3dc6f791569016414af22.js Github

copy

Full Screen

...66 var actions = [];67 env.beforeEach(function () {68 actions.push('topSuite beforeEach');69 });70 env.afterEach(function () {71 actions.push('topSuite afterEach');72 });73 env.describe('Something', function() {74 env.beforeEach(function() {75 actions.push('outer beforeEach');76 });77 env.afterEach(function() {78 actions.push('outer afterEach');79 });80 env.it('does it 1', function() {81 actions.push('outer it 1');82 });83 env.describe('Inner 1', function() {84 env.beforeEach(function() {85 actions.push('inner 1 beforeEach');86 });87 env.afterEach(function() {88 actions.push('inner 1 afterEach');89 });90 env.it('does it 2', function() {91 actions.push('inner 1 it');92 });93 });94 env.it('does it 3', function() {95 actions.push('outer it 2');96 });97 env.describe('Inner 2', function() {98 env.beforeEach(function() {99 actions.push('inner 2 beforeEach');100 });101 env.afterEach(function() {102 actions.push('inner 2 afterEach');103 });104 env.it('does it 2', function() {105 actions.push('inner 2 it');106 });107 });108 });109 var assertions = function() {110 var expected = [111 "topSuite beforeEach",112 "outer beforeEach",113 "outer it 1",114 "outer afterEach",115 "topSuite afterEach",116 "topSuite beforeEach",117 "outer beforeEach",118 "inner 1 beforeEach",119 "inner 1 it",120 "inner 1 afterEach",121 "outer afterEach",122 "topSuite afterEach",123 "topSuite beforeEach",124 "outer beforeEach",125 "outer it 2",126 "outer afterEach",127 "topSuite afterEach",128 "topSuite beforeEach",129 "outer beforeEach",130 "inner 2 beforeEach",131 "inner 2 it",132 "inner 2 afterEach",133 "outer afterEach",134 "topSuite afterEach"135 ];136 expect(actions).toEqual(expected);137 done();138 };139 env.addReporter({jasmineDone: assertions});140 env.execute();141 });142 it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {143 var actions = [];144 env.beforeEach(function () {145 actions.push('runner beforeEach1');146 });147 env.afterEach(function () {148 actions.push('runner afterEach1');149 });150 env.beforeEach(function () {151 actions.push('runner beforeEach2');152 });153 env.afterEach(function () {154 actions.push('runner afterEach2');155 });156 env.describe('Something', function() {157 env.beforeEach(function() {158 actions.push('beforeEach1');159 });160 env.afterEach(function() {161 actions.push('afterEach1');162 });163 env.beforeEach(function() {164 actions.push('beforeEach2');165 });166 env.afterEach(function() {167 actions.push('afterEach2');168 });169 env.it('does it 1', function() {170 actions.push('outer it 1');171 });172 });173 var assertions = function() {174 var expected = [175 "runner beforeEach1",176 "runner beforeEach2",177 "beforeEach1",178 "beforeEach2",179 "outer it 1",180 "afterEach2",181 "afterEach1",182 "runner afterEach2",183 "runner afterEach1"184 ];185 expect(actions).toEqual(expected);186 done();187 };188 env.addReporter({jasmineDone: assertions});189 env.execute();190 });191 it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {192 var actions = [];193 env.beforeAll(function() {194 actions.push('runner beforeAll');195 });196 env.afterAll(function() {197 actions.push('runner afterAll');198 });199 env.beforeEach(function () {200 actions.push('runner beforeEach');201 });202 env.afterEach(function () {203 actions.push('runner afterEach');204 });205 env.describe('Something', function() {206 env.beforeEach(function() {207 actions.push('inner beforeEach');208 });209 env.afterEach(function() {210 actions.push('inner afterEach');211 });212 env.beforeAll(function() {213 actions.push('inner beforeAll');214 });215 env.afterAll(function() {216 actions.push('inner afterAll');217 });218 env.it('does something or other', function() {219 actions.push('it');220 });221 });222 var assertions = function() {223 var expected = [224 "runner beforeAll",225 "inner beforeAll",226 "runner beforeEach",227 "inner beforeEach",228 "it",229 "inner afterEach",230 "runner afterEach",231 "inner afterAll",232 "runner afterAll"233 ];234 expect(actions).toEqual(expected);235 done();236 };237 env.addReporter({jasmineDone: assertions});238 env.execute();239 });240 it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {241 var actions = [],242 spec,243 spec2;244 env.beforeAll(function() {245 actions.push('runner beforeAll');246 });247 env.afterAll(function() {248 actions.push('runner afterAll');249 });250 env.beforeEach(function () {251 actions.push('runner beforeEach');252 });253 env.afterEach(function () {254 actions.push('runner afterEach');255 });256 env.describe('Something', function() {257 env.beforeEach(function() {258 actions.push('inner beforeEach');259 });260 env.afterEach(function() {261 actions.push('inner afterEach');262 });263 env.beforeAll(function() {264 actions.push('inner beforeAll');265 });266 env.afterAll(function() {267 actions.push('inner afterAll');268 });269 spec = env.it('does something', function() {270 actions.push('it');271 });272 spec2 = env.it('does something or other', function() {273 actions.push('it2');274 });275 });276 var assertions = function() {277 var expected = [278 "runner beforeAll",279 "inner beforeAll",280 "runner beforeEach",281 "inner beforeEach",282 "it2",283 "inner afterEach",284 "runner afterEach",285 "runner beforeEach",286 "inner beforeEach",287 "it",288 "inner afterEach",289 "runner afterEach",290 "inner afterAll",291 "runner afterAll"292 ];293 expect(actions).toEqual(expected);294 done();295 };296 env.addReporter({jasmineDone: assertions});297 env.execute([spec2.id, spec.id]);298 });299 it('only runs *Alls once in a focused suite', function(done){300 var actions = [];301 env.fdescribe('Suite', function() {302 env.beforeAll(function(){303 actions.push('beforeAll');304 });305 env.it('should run beforeAll once', function() {306 actions.push('spec');307 });308 env.afterAll(function(){309 actions.push('afterAll');310 });311 });312 var assertions = function() {313 expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);314 done();315 };316 env.addReporter({jasmineDone: assertions});317 env.execute();318 });319 describe('focused runnables', function() {320 it('runs the relevant alls and eachs for each runnable', function(done) {321 var actions = [];322 env.beforeAll(function() {actions.push('beforeAll')});323 env.afterAll(function() {actions.push('afterAll')});324 env.beforeEach(function() {actions.push('beforeEach')});325 env.afterEach(function() {actions.push('afterEach')});326 env.fdescribe('a focused suite', function() {327 env.it('is run', function() {328 actions.push('spec in fdescribe')329 });330 });331 env.describe('an unfocused suite', function() {332 env.fit('has a focused spec', function() {333 actions.push('focused spec')334 });335 });336 var assertions = function() {337 var expected = [338 'beforeAll',339 'beforeEach',340 'spec in fdescribe',341 'afterEach',342 'beforeEach',343 'focused spec',344 'afterEach',345 'afterAll'346 ];347 expect(actions).toEqual(expected);348 done();349 };350 env.addReporter({jasmineDone: assertions});351 env.execute();352 });353 it('focused specs in focused suites cause non-focused siblings to not run', function(done){354 var actions = [];355 env.fdescribe('focused suite', function() {356 env.it('unfocused spec', function() {357 actions.push('unfocused spec')358 });359 env.fit('focused spec', function() {360 actions.push('focused spec')361 });362 });363 var assertions = function() {364 var expected = ['focused spec'];365 expect(actions).toEqual(expected);366 done();367 };368 env.addReporter({jasmineDone: assertions});369 env.execute();370 });371 it('focused suites in focused suites cause non-focused siblings to not run', function(done){372 var actions = [];373 env.fdescribe('focused suite', function() {374 env.it('unfocused spec', function() {375 actions.push('unfocused spec')376 });377 env.fdescribe('inner focused suite', function() {378 env.it('inner spec', function() {379 actions.push('inner spec');380 });381 });382 });383 var assertions = function() {384 var expected = ['inner spec'];385 expect(actions).toEqual(expected);386 done();387 };388 env.addReporter({jasmineDone: assertions});389 env.execute();390 });391 it('focused runnables unfocus ancestor focused suites', function() {392 var actions = [];393 env.fdescribe('focused suite', function() {394 env.it('unfocused spec', function() {395 actions.push('unfocused spec')396 });397 env.describe('inner focused suite', function() {398 env.fit('focused spec', function() {399 actions.push('focused spec');400 });401 });402 });403 var assertions = function() {404 var expected = ['focused spec'];405 expect(actions).toEqual(expected);406 done();407 };408 env.addReporter({jasmineDone: assertions});409 env.execute();410 });411 });412 it("shouldn't run disabled suites", function(done) {413 var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),414 suite = env.describe('A Suite', function() {415 env.xdescribe('with a disabled suite', function(){416 env.it('spec inside a disabled suite', specInADisabledSuite);417 });418 });419 var assertions = function() {420 expect(specInADisabledSuite).not.toHaveBeenCalled();421 done();422 };423 env.addReporter({jasmineDone: assertions});424 env.execute();425 });426 it("should allow top level suites to be disabled", function() {427 var specInADisabledSuite = jasmine.createSpy("specInADisabledSuite"),428 otherSpec = jasmine.createSpy("otherSpec");429 env.xdescribe('A disabled suite', function() {430 env.it('spec inside a disabled suite', specInADisabledSuite);431 });432 env.describe('Another suite', function() {433 env.it('another spec', otherSpec);434 });435 var assertions = function() {436 expect(specInADisabledSuite).not.toHaveBeenCalled();437 expect(otherSpec).toHaveBeenCalled();438 done();439 };440 env.addReporter({jasmineDone: assertions});441 env.execute();442 });443 it("should set all pending specs to pending when a suite is run", function(done) {444 var pendingSpec,445 suite = env.describe('default current suite', function() {446 pendingSpec = env.it("I am a pending spec");447 });448 var assertions = function() {449 expect(pendingSpec.status()).toBe("pending");450 done();451 };452 env.addReporter({jasmineDone: assertions});453 env.execute();454 });455 it("should recover gracefully when there are errors in describe functions", function(done) {456 var specs = [],457 reporter = jasmine.createSpyObj(['specDone', 'jasmineDone']);458 reporter.specDone.and.callFake(function(result) {459 specs.push(result.fullName);460 });461 reporter.jasmineDone.and.callFake(function() {462 expect(specs).toContain('outer1 inner1 should thingy');463 expect(specs).toContain('outer1 inner1 encountered a declaration exception');464 expect(specs).toContain('outer1 inner2 should other thingy');465 expect(specs).toContain('outer1 encountered a declaration exception');466 expect(specs).toContain('outer2 should xxx');467 done();468 });469 expect(function() {470 env.describe("outer1", function() {471 env.describe("inner1", function() {472 env.it("should thingy", function() {473 this.expect(true).toEqual(true);474 });475 throw new Error("fake error");476 });477 env.describe("inner2", function() {478 env.it("should other thingy", function() {479 this.expect(true).toEqual(true);480 });481 });482 throw new Error("fake error");483 });484 }).not.toThrow();485 env.describe("outer2", function() {486 env.it("should xxx", function() {487 this.expect(true).toEqual(true);488 });489 });490 env.addReporter(reporter);491 env.execute();492 });493 it("re-enters suites that have no *Alls", function(done) {494 var actions = [],495 spec1, spec2, spec3;496 env.describe("top", function() {497 spec1 = env.it("spec1", function() {498 actions.push("spec1");499 });500 spec2 = env.it("spec2", function() {501 actions.push("spec2");502 });503 });504 spec3 = env.it("spec3", function() {505 actions.push("spec3");506 });507 env.addReporter({508 jasmineDone: function() {509 expect(actions).toEqual(["spec2", "spec3", "spec1"]);510 done();511 }512 });513 env.execute([spec2.id, spec3.id, spec1.id]);514 });515 it("refuses to re-enter suites with a beforeAll", function() {516 var actions = [],517 spec1, spec2, spec3;518 env.describe("top", function() {519 env.beforeAll(function() {});520 spec1 = env.it("spec1", function() {521 actions.push("spec1");522 });523 spec2 = env.it("spec2", function() {524 actions.push("spec2");525 });526 });527 spec3 = env.it("spec3", function() {528 actions.push("spec3");529 });530 env.addReporter({531 jasmineDone: function() {532 expect(actions).toEqual([]);533 done();534 }535 });536 expect(function() {537 env.execute([spec2.id, spec3.id, spec1.id]);538 }).toThrowError(/beforeAll/);539 });540 it("refuses to re-enter suites with a afterAll", function() {541 var actions = [],542 spec1, spec2, spec3;543 env.describe("top", function() {544 env.afterAll(function() {});545 spec1 = env.it("spec1", function() {546 actions.push("spec1");547 });548 spec2 = env.it("spec2", function() {549 actions.push("spec2");550 });551 });552 spec3 = env.it("spec3", function() {553 actions.push("spec3");554 });555 env.addReporter({556 jasmineDone: function() {557 expect(actions).toEqual([]);558 done();559 }560 });561 expect(function() {562 env.execute([spec2.id, spec3.id, spec1.id]);563 }).toThrowError(/afterAll/);564 });565 it("should run the tests in a consistent order when a seed is supplied", function(done) {566 var actions = [];567 env.randomizeTests(true);568 env.seed('123456');569 env.beforeEach(function () {570 actions.push('topSuite beforeEach');571 });572 env.afterEach(function () {573 actions.push('topSuite afterEach');574 });575 env.describe('Something', function() {576 env.beforeEach(function() {577 actions.push('outer beforeEach');578 });579 env.afterEach(function() {580 actions.push('outer afterEach');581 });582 env.it('does it 1', function() {583 actions.push('outer it 1');584 });585 env.describe('Inner 1', function() {586 env.beforeEach(function() {587 actions.push('inner 1 beforeEach');588 });589 env.afterEach(function() {590 actions.push('inner 1 afterEach');591 });592 env.it('does it 2', function() {593 actions.push('inner 1 it');594 });595 });596 env.it('does it 3', function() {597 actions.push('outer it 2');598 });599 env.describe('Inner 2', function() {600 env.beforeEach(function() {601 actions.push('inner 2 beforeEach');602 });603 env.afterEach(function() {604 actions.push('inner 2 afterEach');605 });606 env.it('does it 2', function() {607 actions.push('inner 2 it');608 });609 });610 });611 var assertions = function() {612 var expected = [613 'topSuite beforeEach',614 'outer beforeEach',615 'outer it 2',616 'outer afterEach',617 'topSuite afterEach',...

Full Screen

Full Screen

Order.js

Source:Order.js Github

copy

Full Screen

...156 afterAll(function() {157 order.push('foo afterAll');158 });159 160 afterEach(function() {161 order.push('foo afterEach 1');162 });163 164 afterEach(function() {165 order.push('foo afterEach 2');166 });167 168 it("foo 1", function() {169 runs(function() {170 order.push('foo it 1-2');171 });172 173 order.push('foo it 1-1');174 175 // If there is a problem this waits() will break async flow176 waits(1);177 178 runs(function() {179 order.push('foo it 1-3');180 });181 });182 183 spec = todo().184 it("foo 2", function() {185 // This is going to time out after 1 invocation186 waitsFor(function() {187 order.push('foo it 2-2');188 return false;189 }, 'foo 2 to run', 1, 10);190 191 order.push('foo it 2-1');192 // Don't try to do this at home!193 this.queue.insertNext(new jasmine.Block(this.env, function() {194 order.push('foo it 2-3');195 }, this), true);196 });197 198 spec = todo().199 it("foo 3", function() {200 order.push('foo it 3-1');201 202 // This is going to time out after 2 invocations203 waitsFor(function() {204 order.push('foo it 3-2');205 return false;206 }, 'foo 3 to run', 20, 10);207 208 this.queue.insertNext(new jasmine.Block(this.env, function() {209 order.push('foo it 3-3');210 }, this), true);211 });212 213 describe("bar", function() {214 beforeAll(function() {215 order.push('bar beforeAll');216 });217 218 beforeEach(function() {219 runs(function() {220 order.push('bar beforeEach runs');221 });222 223 waitsFor(function(done) {224 order.push('bar beforeEach waitsFor');225 done();226 });227 });228 229 afterEach(function() {230 order.push('bar afterEach');231 });232 233 afterAll(function() {234 order.push('bar afterAll');235 });236 237 it("bar 1", function() {238 waitsFor(function() {239 order.push('bar it 1-2');240 return true;241 }, 'bar 1 to run', 10, 10);242 243 runs(function() {244 order.push('bar it 1-3');245 });246 247 order.push('bar it 1-1');248 });249 250 it("bar 2", function() {251 this.counter = 0;252 253 waitsFor(function() {254 order.push('bar it 2-2');255 return this.counter++;256 }, 'bar 1 to run', 100, 10);257 258 runs(function() {259 order.push('bar it 2-3');260 });261 262 order.push('bar it 2-1');263 });264 265 describe("qux", function() {266 beforeEach(function() {267 runs(function() {268 order.push('qux beforeEach 1');269 });270 271 waits(1);272 273 runs(function() {274 order.push('qux beforeEach 2');275 });276 });277 278 afterEach(function() {279 order.push('qux afterEach');280 });281 282 afterAll(function() {283 order.push('qux afterAll');284 });285 286 todo().287 it("qux 1", function() {288 var spy = jasmine.createSpy('qux 1');289 290 order.push('qux it 1');291 292 // This is going to time out...

Full Screen

Full Screen

SinonQunitBridge.qunit.js

Source:SinonQunitBridge.qunit.js Github

copy

Full Screen

...10 baz : function () {}11 };12 // QUnit.todo does not exist in QUnit 1. Use QUnit.test instead -> the errors will be visible.13 QUnit.todo = QUnit.todo || QUnit.test;14 function afterEach() {15 sinon.assert.pass("pass");16 }17 function beforeEach() {18 this.mock(foo).expects("bar").withExactArgs("baz").returns(42);19 }20 var oHooks = {21 beforeEach : beforeEach,22 afterEach : afterEach23 };24 function useMock(assert) {25 assert.strictEqual(foo.bar("baz"), 42, "use mock");26 }27 // QUnit.module("nested 1", function () {});28 // QUnit.module("nested 2", {}, function () {});...

Full Screen

Full Screen

abstract-history.spec.js

Source:abstract-history.spec.js Github

copy

Full Screen

...7 const router = new VueRouter({ mode: 'abstract' })8 const afterEach = jasmine.createSpy('afterEach')9 const onReady = jasmine.createSpy('ready')10 const onError = jasmine.createSpy('error')11 router.afterEach(afterEach)12 router.onReady(onReady, onError)13 router.push('/').finally(() => {14 expect(onReady).toHaveBeenCalled()15 expect(onError).not.toHaveBeenCalled()16 expect(afterEach).toHaveBeenCalled()17 done()18 })19 })20 it('run afterEach after router.go', done => {21 const router = new VueRouter({ mode: 'abstract' })22 const afterEach = jasmine.createSpy('afterEach')23 router24 .push('/')25 .then(() => router.push('/foo'))26 .then(() => {27 router.afterEach(afterEach)28 router.go(-1)29 return delay(30)30 })31 .finally(() => {32 expect(afterEach).toHaveBeenCalled()33 done()34 })35 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('outer', function() {2 console.log('describe outer-a');3 describe('describe inner 1', function() {4 console.log('describe inner 1');5 it('test 1', function() {6 console.log('test for describe inner 1');7 expect(true).toEqual(true);8 });9 });10 console.log('describe outer-b');11 describe('describe inner 2', function() {12 console.log('describe inner 2');13 it('test for describe inner 2', function() {14 console.log('test for describe inner 2');15 expect(false).toEqual(false);16 });17 });18 console.log('describe outer-c');19});20describe('outer', function() {21 console.log('describe outer-a');22 describe('describe inner 1', function() {23 console.log('describe inner 1');24 afterEach(function() {25 console.log('after each');26 });27 it('test 1', function() {28 console.log('test for describe inner 1');29 expect(true).toEqual(true);30 });31 });32 console.log('describe outer-b');33 describe('describe inner 2', function() {34 console.log('describe inner 2');35 afterEach(function() {36 console.log('after each');37 });38 it('test for describe inner 2', function() {39 console.log('test for describe inner 2');40 expect(false).toEqual(false);41 });42 });43 console.log('describe outer-c');44});45describe('outer', function() {46 console.log('describe outer-a');47 beforeEach(function() {48 console.log('before each');49 });50 describe('describe inner 1', function() {51 console.log('describe inner 1');52 it('test 1', function() {53 console.log('test for describe inner 1');54 expect(true).toEqual

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2describe('Array', function() {3 describe('#indexOf()', function() {4 it('should return -1 when the value is not present', function() {5 assert.equal(-1, [1,2,3].indexOf(4));6 });7 it('should return 0 when the value is present', function() {8 assert.equal(0, [1,2,3].indexOf(1));9 });10 });11 describe('#indexOf()', function() {12 it('should return -1 when the value is not present', function() {13 assert.equal(-1, [1,2,3].indexOf(4));14 });15 it('should return 0 when the value is present', function() {16 assert.equal(0, [1,2,3].indexOf(1));17 });18 });19});20 #indexOf()21 #indexOf()

Full Screen

Using AI Code Generation

copy

Full Screen

1afterEach(function(){2 console.log('afterEach called');3});4beforeEach(function(){5 console.log('beforeEach called');6});7after(function(){8 console.log('after called');9});10before(function(){11 console.log('before called');12});13describe('first describe', function(){14 afterEach(function(){15 console.log('afterEach called in first describe');16 });17 beforeEach(function(){18 console.log('beforeEach called in first describe');19 });20 after(function(){21 console.log('after called in first describe');22 });23 before(function(){24 console.log('before called in first describe');25 });26 describe('second describe', function(){27 afterEach(function(){28 console.log('afterEach called in second describe');29 });30 beforeEach(function(){31 console.log('beforeEach called in second describe');32 });33 after(function(){34 console.log('after called in second describe');35 });36 before(function(){37 console.log('before called in second describe');38 });39 describe('third describe', function(){40 afterEach(function(){41 console.log('afterEach called in third describe');42 });43 beforeEach(function(){44 console.log('beforeEach called in third describe');45 });46 after(function(){47 console.log('after called in third describe');48 });49 before(function(){50 console.log('before called in third describe');51 });52 it('should be third test', function(){53 console.log('third test called');54 });55 });56 it('should be second test', function(){57 console.log('second test called');58 });59 });

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Test", function() {2 afterEach(function() {3 console.log("After each");4 });5 it("Test1", function() {6 console.log("Test1");7 });8 it("Test2", function() {9 console.log("Test2");10 });11});12describe("Test", function() {13 describe("Nested", function() {14 afterEach(function() {15 console.log("After each");16 });17 it("Test1", function() {18 console.log("Test1");19 });20 it("Test2", function() {21 console.log("Test2");22 });23 });24});25describe("Test", function() {26 describe("Nested", function() {27 afterEach(function() {28 console.log("After each");29 });30 it("Test1", function() {31 console.log("Test1");32 });33 it("Test2", function() {34 console.log("Test2");35 });36 });37 it("Test3", function() {38 console.log("Test3");39 });40});41describe("Test", function() {42 describe("Nested", function() {43 afterEach(function() {44 console.log("After each");45 });46 it("Test1", function() {47 console.log("Test1");48 });49 it("Test2", function() {50 console.log("Test2");51 });52 });53 it("Test3", function() {54 console.log("Test3");55 });56 it("Test4", function() {57 console.log("Test4");58 });59});60describe("Test", function() {61 describe("Nested", function() {62 afterEach(function() {63 console.log("After each");64 });65 it("Test1", function() {66 console.log("Test1");67 });68 it("Test2", function() {

Full Screen

Using AI Code Generation

copy

Full Screen

1afterEach(() => {2 console.log('afterEach method of root level');3});4describe('Test Suite', () => {5 afterEach(() => {6 console.log('afterEach method of describe level');7 });8 it('Test Case', () => {9 console.log('Test Case');10 });11});12describe('Test Suite', () => {13 it('Test Case', () => {14 console.log('Test Case');15 });16 afterEach(() => {17 console.log('afterEach method of it level');18 });19});20describe('Test Suite', () => {21 afterEach(() => {22 console.log('afterEach method of nested describe level');23 });24 describe('Nested Test Suite', () => {25 it('Test Case', () => {26 console.log('Test Case');27 });28 });29});30describe('Test Suite', () => {31 describe('Nested Test Suite', () => {32 afterEach(() => {33 console.log('afterEach method of nested describe level');34 });35 it('Test Case', () => {36 console.log('Test Case');37 });38 });39});40describe('Test Suite', () => {41 describe('Nested Test Suite', () => {42 it('Test Case', () => {43 console.log('Test Case');44 });45 });46 afterEach(() => {47 console.log('afterEach method of nested describe level');48 });49});50describe('Test Suite', () => {51 describe('Nested Test Suite', () => {52 it('Test Case', () => {53 console.log('Test Case');54 });55 afterEach(() => {56 console.log('afterEach method of nested describe level');57 });58 });59});60describe('Test Suite', () => {61 describe('Nested Test Suite', () => {62 it('Test Case', () => {63 console.log('Test Case');64 });65 });66 afterEach(() => {67 console.log('afterEach method of nested describe level');68 });69});70describe('Test Suite', () => {71 describe('Nested Test Suite

Full Screen

Using AI Code Generation

copy

Full Screen

1afterEach(function(){2 console.log("after each");3});4beforeEach(function(){5 console.log("before each");6});7describe("Test Suite", function(){8 afterEach(function(){9 console.log("after each of describe");10 });11 beforeEach(function(){12 console.log("before each of describe");13 });14 it("Test Case", function(){15 console.log("test case");16 });17 it("Test Case 1", function(){18 console.log("test case 1");19 });20});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Root Describe', function () {2 describe('Child Describe', function () {3 afterEach(function () {4 console.log("afterEach of child describe");5 });6 it('Test Case 1', function () {7 console.log("Test Case 1");8 });9 it('Test Case 2', function () {10 console.log("Test Case 2");11 });12 });13 afterEach(function () {14 console.log("afterEach of root describe");15 });16 it('Test Case 3', function () {17 console.log("Test Case 3");18 });19 it('Test Case 4', function () {20 console.log("Test Case 4");21 });22});23describe('Root Describe', function () {24 describe('Child Describe', function () {25 beforeEach(function () {26 console.log("beforeEach of child describe");27 });28 it('Test Case 1', function () {29 console.log("Test Case 1");30 });31 it('Test Case 2', function () {32 console.log("Test Case 2");33 });34 });35 beforeEach(function () {36 console.log("beforeEach of root describe");37 });38 it('Test Case 3', function () {39 console.log("Test Case 3");40 });41 it('Test Case 4', function () {42 console.log("Test Case 4");43 });44});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Suite', () => {2 describe('Test Suite 1', () => {3 it('Test Case 1', () => {4 });5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

1afterEach(async () => {2 await browser.close();3});4after(async () => {5 await browser.close();6});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function(){2 afterEach(function(){3 console.log('After each');4 });5 it('should pass', function(){6 console.log('Test');7 });8});9describe('Test', function(){10 describe('Nested', function(){11 afterEach(function(){12 console.log('After each');13 });14 it('should pass', function(){15 console.log('Test');16 });17 });18});19describe('Test', function(){20 describe('Nested', function(){21 beforeEach(function(){22 console.log('Before each');23 });24 afterEach(function(){25 console.log('After each');26 });27 it('should pass', function(){28 console.log('Test');29 });30 });31});32describe('Test', function(){33 describe('Nested', function(){34 beforeEach(function(){35 console.log('Before each');36 });37 afterEach(function(){38 console.log('After each');39 });40 it('should pass', function(){41 console.log('Test');42 });43 });44});45describe('Test', function(){46 describe('Nested', function(){47 beforeEach(function(){48 console.log('Before each');49 });50 afterEach(function(){51 console.log('After each');52 });53 it('should pass', function(){54 console.log('Test');55 });56 });57});58describe('Test', function(){59 describe('Nested', function(){60 beforeEach(function(){61 console.log('Before each');62 });63 afterEach(function(){64 console.log('After each');65 });66 it('should pass',

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful