Skip to content

Commit 44e9740

Browse files
committed
Refactor server testing infra
This builds out completely new APIs for testing language servers as well as stubs itself into the existing infra so the existing tests can be migrated incrementally
1 parent 30e4d37 commit 44e9740

File tree

9 files changed

+1043
-269
lines changed

9 files changed

+1043
-269
lines changed

packages/tailwindcss-language-server/src/testing/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterAll, onTestFinished, test, TestOptions } from 'vitest'
1+
import { onTestFinished, test, TestOptions } from 'vitest'
22
import * as fs from 'node:fs/promises'
33
import * as path from 'node:path'
44
import * as proc from 'node:child_process'
@@ -16,7 +16,7 @@ export interface Storage {
1616

1717
export interface TestConfig<Extras extends {}> {
1818
name: string
19-
fs: Storage
19+
fs?: Storage
2020
prepare?(utils: TestUtils): Promise<Extras>
2121
handle(utils: TestUtils & Extras): void | Promise<void>
2222

@@ -43,8 +43,10 @@ async function setup<T>(config: TestConfig<T>): Promise<TestUtils> {
4343

4444
await fs.mkdir(baseDir, { recursive: true })
4545

46-
await prepareFileSystem(baseDir, config.fs)
47-
await installDependencies(baseDir, config.fs)
46+
if (config.fs) {
47+
await prepareFileSystem(baseDir, config.fs)
48+
await installDependencies(baseDir, config.fs)
49+
}
4850

4951
onTestFinished(async (result) => {
5052
// Once done, move all the files to a new location

packages/tailwindcss-language-server/src/tw.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ export class TW {
664664
}),
665665
)
666666
}
667+
668+
// TODO: This is a hack and shouldn't be necessary
669+
if (isTestMode) {
670+
await this.connection.sendNotification('@/tailwindCSS/serverReady')
671+
}
667672
}
668673

669674
private filterNewWatchPatterns(patterns: string[]) {

0 commit comments

Comments
 (0)