I would like my describe block to have access to variables assigned inside the beforeAll function.
For example:
let variable_1;
let variable_2;
beforeAll(async () => {
variable_1 = "hello";
variable_2 = await getVariable_2();
});
describe('Database Testing', () => {
console.log(variable_1); // why is this undefined?
console.log(variable_2); // why is this undefined?
test(`Testing`, async () => {
expect('hi').toEqual('hi');
})
});
How can I do this?
per @Kordrad comment, you need your beforeAll within a describe block
let variable_1; let variable_2;
describe('Database Testing', () => {
beforeAll(async () => {
variable_1 = "hello";
variable_2 = await getVariable_2();
});
test(`Testing`, async () => {
expect('hi').toEqual('hi');
})
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.