Pest Testing Issue: “Cannot declare class” Error with Multiple Tests in Same File
Subject: PestPHP Testing Issue: “Cannot declare class” Error with Multiple Tests in Same File
Hello everyone,
I’m encountering an issue while using the PestPHP testing framework in my project. I have two tests within the same file, and a beforeEach hook:
it("Test something", function () {
// ...logicTest
});
it("Test something else", function () {
// ...logicTest
});
When I run these tests together, I receive the following error:
Cannot declare class App\Filament\Pages\Auth\AppRegister, because the name is already in use
This class (App\Filament\Pages\Auth\AppRegister) is one I created. Interestingly, if I comment out either of the tests, the remaining test runs without any issues.
I suspect there might be a problem with class redeclaration or a lack of proper cleanup between tests. Has anyone faced a similar issue or can provide guidance on what might be going wrong? Am I missing some cleanup steps or configurations in Pest?
Any insights or suggestions would be greatly appreciated. Thank you!
Hello everyone,
I’m encountering an issue while using the PestPHP testing framework in my project. I have two tests within the same file, and a beforeEach hook:
it("Test something", function () {
// ...logicTest
});
it("Test something else", function () {
// ...logicTest
});
When I run these tests together, I receive the following error:
Cannot declare class App\Filament\Pages\Auth\AppRegister, because the name is already in use
This class (App\Filament\Pages\Auth\AppRegister) is one I created. Interestingly, if I comment out either of the tests, the remaining test runs without any issues.
I suspect there might be a problem with class redeclaration or a lack of proper cleanup between tests. Has anyone faced a similar issue or can provide guidance on what might be going wrong? Am I missing some cleanup steps or configurations in Pest?
Any insights or suggestions would be greatly appreciated. Thank you!