I am currently exploring Jasmine and attempting to incorporate shared steps in my test cases. I want to reuse certain steps between two scenarios, but when I try to execute a common describe block inside an it block, it does not run as expected. Here is a simplified example of the code:
describe('Main Method 1', (){
it('Function 1', (){
console.log('Function 1');
describe('Function 1',(){
it('Function 1.1',(){
console.log('Function 1.1');
})
it('Function 1.2',(){
console.log('Function 1.2');
})
});
});
it('Function 2', (){
console.log('Function 2');
describe('Function 2',(){
it('Function 2.1',(){
console.log('Function 2.1');
})
it('Function 2.2',(){
console.log('Function 2.2');
})
});
});
});
The issue here is that Function 1 & Function 2 are considered separate scenarios and I am looking for a way to share specific scenarios within Main Method 1.
While Function 1 & Function 2 get printed, the nested steps like Function 1.1, Function 1.2, Function 2.1, and Function 2.2 do not appear in the output.
If anyone has any insights or suggestions on this matter, I would greatly appreciate it.
In a more practical implementation scenario, the structure might be similar to:
describe('Main Method', (){
it('F1', () {
Function1();
});
it('F2', () {
Function2();
});
});
Function1(){
describe('Function 1',(){
it('Function 1.1',(){
console.log('Function 1.1');
})
it('Function 1.2',(){
console.log('Function 1.2');
})
});
}
Function2(){
describe('Function 2',(){
it('Function 2.1',(){
console.log('Function 2.1');
})
it('Function 2.2',(){
console.log('Function 2.2');
})
});
}