Use Data Table in Before()

I’m attempting to use the data from my DataTable in the before() method of my test. However I’m getting an error that “current is not defined in container”. Is this because the Before method cannot access the data? If so, is there any other way to access the data for a test from the Before method?

Before(({I, current}) => {
I.amOnPage("/");
I.fillField("#username", current.username);
I.fillField("#password", current.password);
})

let login = new DataTable([‘username’, ‘password’]);
login.add([‘myUsername’, ‘myPassword’])

Data(login).Scenario(‘Test Login’, async ({ I, CXE, current }) => {
I.see(“Welcome”)
})

Yes, you are creating the login variable only after Before, so it does not exist

let login = new DataTable([‘username’, ‘password’]);
login.add([‘myUsername’, ‘myPassword’])

Before(({I, current}) => {
I.amOnPage("/");
I.fillField("#username", current.username);
I.fillField("#password", current.password);
})

Data(login).Scenario(‘Test Login’, async ({ I, CXE, current }) => {
I.see(“Welcome”)
})

So changing the code, I still get the same error as it seems like the current object is not in scope for the Before method.

let login = new DataTable([‘username’, ‘password’]);
login.add([‘myUsername’, ‘myPassword’])

Before(({I, current}) => {
I.amOnPage("/");
I.fillField("#username", current.username);
I.fillField("#password", current.password);
})

Data(login).Scenario(‘Test Login’, async ({ I, CXE, current }) => {
I.see(“Welcome”)
})

Correct, I use Background for all login work where it is a fixed loginFunction, and with data, it only works in scenario as the data is literally passed to the scenario