0
votes

I am trying to implement a fixture with multiple tests where all depend on each other Therefore I want to clean the Database and perform login only one time from the Fixture.before Method So it will look like this:

fixture `testProject`.page(baseUrl)
    .before(async t => {
    await loginPM.login()
    await base.clearDB()
})
.beforeEach(async t => {
// some steps before each test
})
test 1
test 2 
test 3

This scenario throws the following exception:


Error in fixture.before hook - Cannot implicitly resolve the test run in the context of which the test controller action should be executed. Use test function's 't' argument instead


Any ideas why testcafe not support calling functions from a Fixture.before Method

1

1 Answers

1
votes

The fixture.before hook runs between tests and doesn't have access to the tested page. Please refer to the following help topic for details on its use: Fixture.before Method. If you need to execute test actions (click, typeText, etc) once per fixture before you start all tests, see this module: testcafe-once-hook module. Here is an example of how to use it: https://github.com/AlexKamaev/testcafe-once-hook-example.