- Mastering React Test:Driven Development
- Daniel Irvine
- 83字
- 2021-06-24 14:45:03
Promoting variables
Both of our tests use the same two variables: container and customer. We can pull up these declarations to the outer describe scope, but leave the definitions within the tests. Since we'll be splitting declaration and definition, that also means we'll need to use let instead of const:
Just above the first test, write the following two lines:
let container;
let customer;
Then, remove the word const from both of the tests, and re-run your tests, which should still be passing.