|
| 1 | +'use strict'; |
| 2 | +const{ test, describe, it, before, after, beforeEach, afterEach }=require('node:test'); |
| 3 | +constassert=require("assert"); |
| 4 | + |
| 5 | +// This file should not have any global tests to reproduce bug #48844 |
| 6 | +consttestArr=[]; |
| 7 | + |
| 8 | +before(()=>testArr.push('global before')); |
| 9 | +after(()=>{ |
| 10 | +testArr.push('global after'); |
| 11 | + |
| 12 | +try{ |
| 13 | +assert.deepStrictEqual(testArr,[ |
| 14 | +'global before', |
| 15 | +'describe before', |
| 16 | + |
| 17 | +'describe beforeEach', |
| 18 | +'describe it 1', |
| 19 | +'describe afterEach', |
| 20 | + |
| 21 | +'describe beforeEach', |
| 22 | +'describe test 2', |
| 23 | +'describe afterEach', |
| 24 | + |
| 25 | +'describe nested before', |
| 26 | + |
| 27 | +'describe beforeEach', |
| 28 | +'describe nested beforeEach', |
| 29 | +'describe nested it 1', |
| 30 | +'describe afterEach', |
| 31 | +'describe nested afterEach', |
| 32 | + |
| 33 | +'describe beforeEach', |
| 34 | +'describe nested beforeEach', |
| 35 | +'describe nested test 2', |
| 36 | +'describe afterEach', |
| 37 | +'describe nested afterEach', |
| 38 | + |
| 39 | +'describe nested after', |
| 40 | +'describe after', |
| 41 | +'global after', |
| 42 | +]); |
| 43 | +}catch(e){ |
| 44 | +// TODO(rluvaton): remove the try catch after #48867 is fixed |
| 45 | +console.error(e); |
| 46 | +process.exit(1); |
| 47 | +} |
| 48 | +}); |
| 49 | + |
| 50 | +describe('describe hooks with no global tests',()=>{ |
| 51 | +before(()=>{ |
| 52 | +testArr.push('describe before'); |
| 53 | +}); |
| 54 | +after(()=>{ |
| 55 | +testArr.push('describe after'); |
| 56 | +}); |
| 57 | +beforeEach(()=>{ |
| 58 | +testArr.push('describe beforeEach'); |
| 59 | +}); |
| 60 | +afterEach(()=>{ |
| 61 | +testArr.push('describe afterEach'); |
| 62 | +}); |
| 63 | + |
| 64 | +it('1',()=>testArr.push('describe it 1')); |
| 65 | +test('2',()=>testArr.push('describe test 2')); |
| 66 | + |
| 67 | +describe('nested',()=>{ |
| 68 | +before(()=>{ |
| 69 | +testArr.push('describe nested before') |
| 70 | +}); |
| 71 | +after(()=>{ |
| 72 | +testArr.push('describe nested after') |
| 73 | +}); |
| 74 | +beforeEach(()=>{ |
| 75 | +testArr.push('describe nested beforeEach') |
| 76 | +}); |
| 77 | +afterEach(()=>{ |
| 78 | +testArr.push('describe nested afterEach') |
| 79 | +}); |
| 80 | + |
| 81 | +it('nested 1',()=>testArr.push('describe nested it 1')); |
| 82 | +test('nested 2',()=>testArr.push('describe nested test 2')); |
| 83 | +}); |
| 84 | +}); |
0 commit comments