If my code is:
context('The Test', () => {
let testStr = 'Test A'
it(`This test is ${testStr}`, () => {
expect(testStr).to.eq('Test A')
})
testStr = 'Test B'
it(`This test is ${testStr}`, () => {
expect(testStr).to.eq('Test B')
})
testStr = 'Test C'
it(`This test is ${testStr}`, () => {
expect(testStr).to.eq('Test C')
})
})
This image has the resulting tests -- My usage of testStr inside the backticks works the way I want it to (indicated by output having the correct test titles of Test A, Test B, and Test C), but the usage of testStr in the expect(testStr).to.eq
cases fails the first 2 tests because testStr is always 'Test C' for these checks. Why does this occur, and how can I write this differently to do what I want?