[4.4.1] Global class "UnitTest" not found after declaration, requires editor restart

Godot Version 4.4.1

Godot version: 4.4.1

OS/Platform: Windows 10

Issue description:
After declaring a global class using class_name UnitTest, the editor cannot find the class until restart. This happens even after:

  • Creating a new script with class_name UnitTest
  • Waiting for full project recompilation
  • Checking that the script is in the correct directory
  • Verifying there are no syntax errors

Steps to reproduce:

  1. Create a new script with class_name UnitTest
  2. Try to use UnitTest in another script
  3. Get errors:
    • “Could not find type ‘UnitTest’ in the current scope”
    • “Identifier ‘UnitTest’ not declared in the current scope”
  4. Restart the editor
  5. The class becomes available

Expected behavior:
The global class should be available immediately after declaration, without requiring editor restart.

Additional context:

  • The issue seems related to .godot/global_script_class_cache.cfg
  • Deleting the .godot folder and reopening the project sometimes helps
  • This is a common issue that affects workflow when adding new global classes

Question:
Is this a known issue? Are there any workarounds besides restarting the editor?

I’ve not personally found any issue like this. Just to be sure, are you saving the UnitTest script before trying to use it?

You could try searching for a similar issue in the issue tracker or open a new one.