How to do unit tests of JavaScript PSI?

Hi,

I’m trying to do some unit tests on PSI element of a javascript file.

I’m quite sure something like that was working (on another project with different setup), before version 2026 or a bit earlier.

Here is my build.gradle.kts

import org.jetbrains.intellij.platform.gradle.TestFrameworkType

plugins {
    id("java")
    id("org.jetbrains.kotlin.jvm")
    id("org.jetbrains.changelog")
    id("org.jetbrains.intellij.platform")
}

dependencies {
    testImplementation(libs.junit)

    intellijPlatform {
        intellijIdea("2026.1")

        testFramework(TestFrameworkType.Platform)
        testFramework(TestFrameworkType.Plugin.JavaScript)

        bundledPlugin("JavaScript")
        testBundledPlugin("JavaScript")
    }
}

The test file src/test/testData/test.js

export default class Test {}

And the test file src/test/java/foo/bar/JsTest.java

import com.intellij.lang.javascript.JavascriptLanguage;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;

public class JsTest extends BasePlatformTestCase {
	@Override
	protected String getTestDataPath() {
		return "src/test/testData";
	}

	public void testFindClassFromCustomElementAnnotation() {
		myFixture.configureByFile("test.js");
		final var file = myFixture.getFile();

		assertSame(JavascriptLanguage.INSTANCE, file.getLanguage());
	}
}

It fails, file is of type PLAIN_TEXT, not javascript. I can’t get JavaScript PSI elements.

In debug on file variable I can see things like that:

myFileType: "AbstractFileType JavaScript; com.intellij.ide.highlighter.custom.SyntaxTable@bfc90f91"
myElementType: "PLAIN_TEXT_FILE"

I tried inheriting random stuff like that, but always getting a plain text file.

JSDaemonAnalyzerLightTestCase
JSTempDirFixtureTestBase
JSImportHighlightingAndCompletionLightTestBase
JSHighlightingAndCompletionLightTestBase